

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: DoS
incomplete
2: Rate Limiting
incomplete
3: Protecting Auth from Abuse
incomplete
4: Throttling Requests
incomplete
5: Queuing Work
incomplete
6: Resource Limits
incomplete
7: Timeouts
incomplete
8: Usage Quotas
incomplete
9: DDoS
incomplete
10: Mitigating DDoS
incomplete
11: Bot Detection
incomplete
12: CAPTCHA
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Requests that take too long will hold connections open and consume server resources, making DoS attacks much more effective. Node has separate timeouts for receiving headers and the request body:
const server = app.listen(3000);
server.headersTimeout = 10_000; // receive complete headers
server.requestTimeout = 30_000; // receive the complete request body
These settings limit how long the client can take to send a request, but they do not cancel a slow route handler. If you have a potentially expensive operation and want to time out your own handler, pass an AbortSignal to the API doing the work:
const signal = AbortSignal.timeout(2_000);
return fetch("https://shipping.example/reservations", {
method: "POST",
body: JSON.stringify(order),
signal, // propagate the timeout
});
After two seconds, the signal aborts and fetch rejects (because fetch is built to support AbortSignal). These kinds of timeouts are useful for database queries, third-party API calls, or any other work that can hang indefinitely.
Bearly Secure's simulated Acorn fulfillment reservation can stall checkout indefinitely.
Bound both incoming requests and the fulfillment call.
With Bearly Secure still running, run and submit the CLI tests from the project root.