Timeouts bound different phases of a connection or request. Configure them with body limits and concurrency controls rather than treating one timeout as universal.
Before you start
You should know JavaScript promises, asynchronous errors and the distinction between a process and a request. When following a server example, identify the resource owner and the point where work completes. Try experiments locally with bounded input instead of assuming production traffic behaves like a single request.
The practical goal is to reason through this situation: A slow upload and a slow upstream response need different ownership and deadlines. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Separate request phases
Connection setup, receiving a body and waiting for an upstream response have different owners and timeout policies.
Step 2: Combine resource bounds
Add body limits and concurrency bounds rather than expecting a single timeout to prevent every overload.
Step 3: Propagate cancellation
When the client disconnects or the operation expires, stop owned downstream work where supported.
Worked scenario
A slow upload and a slow upstream response need different ownership and deadlines.
A proxy receives a slow upload, then waits on a slow upstream. The upload limit does not automatically bound the upstream call, and returning a timeout does not itself stop a background computation. Model each deadline and cancellation path explicitly, including what happens after response bytes have started.
Common mistake
A request timeout does not necessarily cancel downstream work automatically.
Verify the behavior
Test slow headers, slow bodies, stalled upstream and disconnected clients. Confirm configured limits trigger the intended cleanup.
Interview exercise
Protect a proxy endpoint.
Answer and reasoning
Set relevant timeouts, propagate cancellation and cap buffered bytes; verify the behavior for slow and disconnected clients.
Continue learning
Compare the scenario with the Node.js interview questions and test your understanding with the Node.js MCQs. For terminology and implementation details, consult the reference material.