Skip to content

Commit db2eaba

Browse files
committed
docs: explain why the extension long poll never resolves
The extension registers with `{"events": []}` and then parks on GET /2020-01-01/extension/event/next forever. Nothing said why, so the standing question "the long poll is not re-established after a SnapStart restore -- is that a leak or a crash risk?" kept coming back. It is neither, and the empty events list is the reason. Being registered at all is the entire point: Lambda only delivers SIGTERM at environment shutdown when an extension is registered, which is what the graceful-shutdown feature relies on. Subscribing to nothing means RAPID has no event to deliver, so the long poll is never going to resolve -- parking on it IS what keeps the extension alive. Under SnapStart that request is captured mid-flight in the snapshot and never re-established, which is harmless for the same reason, and RAPID's registration state is part of the snapshotted microVM so the effect survives even though the connection does not. Verified on a deployed SnapStart container function: the restored environment received SIGTERM 457s after restore, in the same log stream that logged after_restore, and the failure path that would exit(1) never fired across ~8 minutes and five restores. A non-SnapStart control on $LATEST behaved identically apart from the clocks (monotonic_delta == wall_delta on a normal cold start, versus 0.38s against 184.3s across a restore). Re-registering after restore would be robustness, not a fix. Comment-only; no behavior change.
1 parent db2572f commit db2eaba

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/lib.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,23 @@ impl Adapter<HttpConnector, Body> {
12481248
///
12491249
/// Registers with the Lambda Extensions API and waits for the next event.
12501250
/// This keeps the extension alive for the duration of the Lambda instance.
1251+
///
1252+
/// The registration subscribes to **no events** (`{"events": []}`), deliberately.
1253+
/// Being registered at all is the entire point: Lambda only sends `SIGTERM` at
1254+
/// environment shutdown when an extension is registered, which is what the
1255+
/// graceful-shutdown feature relies on. Because nothing is subscribed, RAPID has
1256+
/// no event to deliver, so the `GET /event/next` call below never resolves — the
1257+
/// spawned task parks on it for the life of the process by design, and that is
1258+
/// what "keeps the extension alive".
1259+
///
1260+
/// Under SnapStart that parked request is captured mid-flight in the snapshot and
1261+
/// is never re-established after a restore. That is harmless for the same reason:
1262+
/// it was never going to resolve, and RAPID's *registration* state is part of the
1263+
/// snapshotted microVM, so the effect survives even though the connection does
1264+
/// not. Verified on a deployed SnapStart container function — the restored
1265+
/// environment received `SIGTERM` 457s after restore, and the failure path below
1266+
/// (which would `exit(1)`) never fired across ~8 minutes and five restores.
1267+
/// Re-registering after restore would be robustness, not a fix.
12511268
async fn register_extension_internal() -> Result<(), Error> {
12521269
// Prefer the original (pre-proxy) value if apply_runtime_proxy_config() captured one.
12531270
// Otherwise fall back to the current env var.

0 commit comments

Comments
 (0)