Skip to content

Commit cefdf52

Browse files
committed
docs(examples): correct the after-restore hook deadline
Both SnapStart example READMEs still said the after-restore hook must finish within the function timeout, which happens to be 10 seconds in these templates — a coincidence that makes the wrong rule look right. The bound is Lambda's 10-second Restore phase limit, shared with the readiness check that follows the hook, and it does not move when the function timeout does. Follow-up to 9484cef, which fixed the same claim in the README, the guide, and the source.
1 parent 282be2a commit cefdf52

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

examples/fastapi-snapstart-zip/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To get more information of Wrapper script, please read Lambda documentation [her
2424
2. `AWS_LWA_SNAPSTART_AFTER_RESTORE_PATH` is set to `/snapstart/after`. The adapter sends an empty HTTP `POST` to this path over the refreshed connection. The app uses it to re-establish connections and regenerate per-environment unique values (in this example, it reconnects the pool and generates a fresh `connection_id`).
2525
3. It re-runs the readiness check against your app before admitting traffic.
2626

27-
Both hook routes must return a `2xx` status code. A non-2xx response or a connection failure fails the SnapStart phase. The adapter sets no deadline of its own — the after-restore hook must finish within the function timeout (`10` seconds in this template). The readiness check runs on every restore; by default it waits indefinitely for the app to recover, but you can bound it with `AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS` (fractional seconds allowed), in which case a restore whose app does not report ready within that timeout fails — so traffic is never served against an app that has not finished recovering.
27+
Both hook routes must return a `2xx` status code. A non-2xx response or a connection failure fails the SnapStart phase. The adapter sets no deadline of its own — but Lambda allows the whole `Restore` phase only [10 seconds](https://docs.aws.amazon.com/lambda/latest/dg/snapstart-troubleshooting.html), regardless of the function timeout, and the after-restore hook shares that window with the readiness check that follows it. The readiness check runs on every restore; by default it waits indefinitely for the app to recover, but you can bound it with `AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS` (fractional seconds allowed), in which case a restore whose app does not report ready within that timeout fails — so traffic is never served against an app that has not finished recovering. A bound above the 10-second `Restore` limit cannot take effect; Lambda times the phase out first.
2828

2929
These hook routes are protected on the Lambda invocation path: the 403 guard lives in the adapter, which only sits in front of your app while it processes Lambda events, so external callers that reach the function (via API Gateway or ALB) and request `/snapstart/before` or `/snapstart/after` receive a `403 Forbidden`. (The guard exists only when the adapter is in the request path — if you run your app without the adapter, protect or don't expose these state-mutating routes yourself.)
3030

examples/fastapi-snapstart/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ snapshot boundary:
5252
3. It re-runs the readiness check against your app before admitting traffic.
5353

5454
Both hook routes must return a `2xx` status code. A non-2xx response or a connection
55-
failure fails the SnapStart phase. The adapter sets no deadline of its own — the
56-
after-restore hook must finish within the function timeout (`10` seconds here).
57-
The readiness check runs on every restore; by default it waits indefinitely for the
58-
app to recover, but you can bound it with `AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS`
59-
(fractional seconds allowed), in which case a restore whose app does not report
60-
ready within that timeout fails — so traffic is never served against an app that has
61-
not finished recovering.
55+
failure fails the SnapStart phase. The adapter sets no deadline of its own — but
56+
Lambda allows the whole `Restore` phase only
57+
[10 seconds](https://docs.aws.amazon.com/lambda/latest/dg/snapstart-troubleshooting.html),
58+
regardless of the function timeout, and the after-restore hook shares that window with
59+
the readiness check that follows it. The readiness check runs on every restore; by
60+
default it waits indefinitely for the app to recover, but you can bound it with
61+
`AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS` (fractional seconds allowed), in which case a
62+
restore whose app does not report ready within that timeout fails — so traffic is never
63+
served against an app that has not finished recovering. A bound above the 10-second
64+
`Restore` limit cannot take effect; Lambda times the phase out first.
6265

6366
These hook routes are protected **on the Lambda invocation path**: the 403 guard
6467
lives in the adapter, which only sits in front of your app when it is processing

0 commit comments

Comments
 (0)