Loading
Current section: Network 7 exercises
Problem

Response delay

Loading exercise

Transcript

00:00 By now, we've handled a bunch of network-related scenarios, from successful responses to error responses, and even network errors, and still there's more to the network. What happens if the request we're making never receives a response? It doesn't error, it simply hands forever.

00:18 Well, in that case, it'd be nice to abort it, to time that out. For that, I've refactored our function to introduce a timeout promise that simply rejects with a timeout error, up to three seconds, and then I introduce a promise race condition between the actual response promise and the timeout promise.

00:37 So whichever rejects or resolves first, wins. Your task in this exercise is to complete a new test case for the timeout scenario. Basically, to make sure that if the request takes more than three seconds to complete, it will be rejected with this particular error message. And keep in mind, you're working with time,

00:56 which you know how to mock and advance.