Skip to content

fix(deno): Don't throw in Deno.serve wrapper when no client is bound - #24030

Open
JosephDoUrden wants to merge 1 commit into
getsentry:developfrom
JosephDoUrden:fix/deno-serve-no-client
Open

fix(deno): Don't throw in Deno.serve wrapper when no client is bound#24030
JosephDoUrden wants to merge 1 commit into
getsentry:developfrom
JosephDoUrden:fix/deno-serve-no-client

Conversation

@JosephDoUrden

Copy link
Copy Markdown
  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Replaces the throw with a debug.warn plus pass-through to the user's handler. Cloudflare's wrapper never blocks the request when the client is missing, this brings Deno in line.

One correction to the issue's mechanism from testing it: Sentry.close() doesn't actually leave getClient() undefined, it flushes and disables but the client stays bound, and a failed second init leaves the first client bound too, so neither path hit this throw. What does reproduce it is a directly constructed client, new DenoClient plus client.init() installs the Deno.serve patch without ever calling setCurrentClient, so the patch is live with no client bound and every request 500s. Either way the wrapper shouldn't be the thing that kills the request.

Trade-off stated plainly: this turns a loud failure into a silent one, the warn only shows with debug enabled, and Cloudflare's equivalent doesn't warn at all there.

Two tests, own file since they wipe the carrier: a plain request comes back 200, and a throwing handler still yields a 500 rather than a crash. Both assert Deno.serve was actually patched first so they can't pass vacuously.

deno suite passed, oxlint and oxfmt clean.

Closes #23894

The Deno.serve patch is installed by Client.init(), which a directly
constructed client also runs without ever calling setCurrentClient, so
the patch can be live with no client bound and every incoming request
threw before reaching the user's handler. Pass through to the handler
with a debug warning instead; the Cloudflare wrapper likewise never
blocks a request when the client is missing.

Fixes getsentry#23894
@JosephDoUrden
JosephDoUrden requested a review from a team as a code owner September 3, 2026 21:13
@JosephDoUrden
JosephDoUrden requested review from isaacs and mydea and removed request for a team September 3, 2026 21: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.

Deno.serve wrapper throws when there is no client

1 participant