fix(deno): Don't throw in Deno.serve wrapper when no client is bound - #24030
Open
JosephDoUrden wants to merge 1 commit into
Open
fix(deno): Don't throw in Deno.serve wrapper when no client is bound#24030JosephDoUrden wants to merge 1 commit into
JosephDoUrden wants to merge 1 commit into
Conversation
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
requested review from
isaacs and
mydea
and removed request for
a team
September 3, 2026 21:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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