You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(snapstart): drop the redundant pre-snapshot readiness gate
With AWS_LWA_ASYNC_INIT ignored under SnapStart, check_init_health takes its
blocking path and `main` awaits it before `run()` — so the application is already
ready by the time before_snapshot runs. The gate only duplicated that invariant in a
second place.
The one case it still covered was a library consumer calling Adapter::new() then
run() while skipping check_init_health(). That is not a coherent guarantee for them
anyway: it would protect the snapshot while leaving their invocations unguarded,
since they also skip ready_at_init and so never get the first-request re-check. If
someone re-enables async_init under SnapStart, the test on effective_async_init
fails, which is an earlier and louder signal than a runtime wait.
Removes the gate, the two tests written for it, and a duplicate happy-path test it
left behind. `ensure_ready`'s `phase` parameter goes too — after_restore is now its
only caller, so it was a parameter with one possible value.
Docs reconciled with the removal: the guide's lifecycle step 1 no longer claims a
pre-snapshot wait (initialization already did it),
AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS bounds two waits again rather than three, and
the CHANGELOG's "hooks firing before the application is ready" fix folds into the
async_init entry, which is where the actual fix lives.
Copy file name to clipboardExpand all lines: docs/guide/src/features/snapstart.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,13 @@ Both hooks are opt-in and independent — each fires only when its variable is s
15
15
16
16
The adapter always registers for the SnapStart lifecycle; the Lambda runtime invokes the hooks only when your function runs under SnapStart. When it does, the adapter participates as follows:
17
17
18
-
1.**Before checkpoint** — the adapter first waits for your application to pass the readiness check, so a snapshot is never taken of a still-booting app. Then, if `AWS_LWA_SNAPSTART_BEFORE_CHECKPOINT_PATH` is set, it sends an empty `POST` to that path, and signals Lambda that it is ready for the snapshot.
18
+
1.**Before checkpoint** — if `AWS_LWA_SNAPSTART_BEFORE_CHECKPOINT_PATH` is set, the adapter sends an empty `POST`to that path on your application, then signals Lambda that it is ready for the snapshot. Initialization has already waited for your application to report ready by this point, so the snapshot is never taken of a still-booting app.
19
19
20
20
2.**After restore** — Lambda restores the environment. The adapter first refreshes its own HTTP connection to your application (so it never reuses a connection captured in the snapshot); then, if `AWS_LWA_SNAPSTART_AFTER_RESTORE_PATH` is set, sends an empty `POST` to that path; and finally re-runs the readiness check before admitting traffic.
21
21
22
22
> **Note:**`AWS_LWA_ASYNC_INIT` is ignored under SnapStart (and under Provisioned Concurrency). It works around the short initialization limit for on-demand cold starts by reporting init complete before the application is ready; neither of those environments has that limit, and finishing early would snapshot — or serve — a half-initialized application. The adapter logs a warning when it ignores the setting.
23
23
24
-
Each hook is an empty `POST`, and your application must respond with a `2xx` status. A non-`2xx` response or a connection failure fails the SnapStart phase — initialization for the before-checkpoint hook, restore for the after-restore hook — rather than serving traffic against an improperly prepared application. The adapter does not impose its own deadline on a hook: Lambda already bounds both phases, and the after-restore hook in particular must complete within your function timeout, so keep that in mind when a hook does slow work such as draining a large connection pool. The final readiness check runs on every restore (whether or not an after-restore path is configured). By default this readiness wait is unbounded; set `AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS` (fractional seconds allowed, e.g. `0.5`) to bound it, in which case a restore whose application does not report ready within that timeout fails. The same variable also bounds the initial cold-start readiness check and the pre-snapshot wait in step 1: when set and the application does not report ready within the timeout, initialization fails (the Lambda runtime never starts) rather than serving traffic — or snapshotting — an app that never came up.
24
+
Each hook is an empty `POST`, and your application must respond with a `2xx` status. A non-`2xx` response or a connection failure fails the SnapStart phase — initialization for the before-checkpoint hook, restore for the after-restore hook — rather than serving traffic against an improperly prepared application. The adapter does not impose its own deadline on a hook: Lambda already bounds both phases, and the after-restore hook in particular must complete within your function timeout, so keep that in mind when a hook does slow work such as draining a large connection pool. The final readiness check runs on every restore (whether or not an after-restore path is configured). By default this readiness wait is unbounded; set `AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS` (fractional seconds allowed, e.g. `0.5`) to bound it, in which case a restore whose application does not report ready within that timeout fails. The same variable also bounds the initial cold-start readiness check, which under SnapStart is what guarantees the application is ready before the snapshot: when set and the application does not report ready within the timeout, initialization fails (the Lambda runtime never starts) rather than snapshotting or serving an app that never came up.
0 commit comments