Skip to content

fix(runtime-sdk): improve ASGI lifespan failure reporting - #172

Draft
whitphx wants to merge 1 commit into
cloudflare:mainfrom
whitphx:fix/asgi-lifespan-failure-reporting
Draft

fix(runtime-sdk): improve ASGI lifespan failure reporting#172
whitphx wants to merge 1 commit into
cloudflare:mainfrom
whitphx:fix/asgi-lifespan-failure-reporting

Conversation

@whitphx

@whitphx whitphx commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Three gaps in start_application's failure paths:

  1. lifespan.startup.failed surfaced as RuntimeError(message) with no __cause__. The app's own exception, which frameworks like Starlette re-raise inside the lifespan task right after sending failed, only reached a background log line as text. It is now chained as the reported error's cause, on both the startup and shutdown failure paths.
  2. An exception raised before the startup ack is still treated as "app doesn't support lifespan" per the spec, but is now logged at debug level instead of vanishing. Previously a crash mid-startup looked identical to an app with no lifespan handler.
  3. An empty-but-present message produced RuntimeError('') on both failure paths; a .get default only applies when the key is absent.

pytest -k asgi in packages/runtime-sdk runs the workerd suite, which covers one test per case above.

@whitphx
whitphx marked this pull request as draft July 30, 2026 19:33
@whitphx
whitphx force-pushed the fix/asgi-lifespan-failure-reporting branch 2 times, most recently from 38cde7d to ee1be54 Compare August 10, 2026 05:25
A reported startup or shutdown failure surfaced as a bare RuntimeError,
losing the app's own exception; an exception raised before the startup
ack vanished entirely; and an empty message produced RuntimeError('').
@whitphx
whitphx force-pushed the fix/asgi-lifespan-failure-reporting branch from ee1be54 to 0a9df8c Compare August 11, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant