Skip to content

Commit f38fd2a

Browse files
committed
Merge branch 'main' into develop
2 parents ed31d5c + 5114533 commit f38fd2a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

website/docs/writing-middlewares/05-timeouts.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Handle Timeouts
33
position: 5
44
---
55

6-
When a lambda times out it throws an error that cannot be caught by middy. To work around this middy maintains an `AbortController` that can be signalled early to allow time to clean up and log the error properly.
6+
When a lambda times out, it throws an error that cannot be caught by middy. To work around this, middy maintains an `AbortController` that can be signalled early to allow time to clean up and log the error properly.
77

88
You can set `timeoutEarlyInMillis` to 0 to disable this functionality. If you want to override during testing, mock the lambda context to set `getRemainingTimeInMillis` to a function that returns a very large value (e.g. `() => 99999`).
99

@@ -26,3 +26,13 @@ export const handler = middy({
2626
}
2727
}).handler(lambdaHandler)
2828
```
29+
30+
**Notes**
31+
32+
Do not mistake `timeoutEarlyInMillis` for a “timeout threshold”, as this is not something middy can control.
33+
The actual timeout of a Lambda function is controlled by AWS and you can configure it at the infrastructure level (with a hard limit of 15 minutes),
34+
see docs https://docs.aws.amazon.com/lambda/latest/dg/configuration-timeout.html
35+
36+
`timeoutEarlyInMillis` gives you a small buffer of time to perform cleanup or logging before Lambda forcibly terminates the function.
37+
38+
Example: If your Lambda timeout is 10s and you set `timeoutEarlyInMillis: 1000`, middy will abort at _approximately_ 9s, leaving about 1s for cleanup.

0 commit comments

Comments
 (0)