René's URL Explorer Experiment


Title: [cloudflare] scheduled handler: raw `waitUntil(flushAndDispose(client))` fails every cron invocation with silent outcome=exception · Issue #21950 · getsentry/sentry-javascript · GitHub

Open Graph Title: [cloudflare] scheduled handler: raw `waitUntil(flushAndDispose(client))` fails every cron invocation with silent outcome=exception · Issue #21950 · getsentry/sentry-javascript

X Title: [cloudflare] scheduled handler: raw `waitUntil(flushAndDispose(client))` fails every cron invocation with silent outcome=exception · Issue #21950 · getsentry/sentry-javascript

Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...

Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...

X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...

Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/21950

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[cloudflare] scheduled handler: raw `waitUntil(flushAndDispose(client))` fails every cron invocation with silent outcome=exception","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues [https://github.com/getsentry/sentry-javascript/issues](\u003chttps://github.com/getsentry/sentry-javascript/issues>)\n- [X] I have reviewed the documentation [https://docs.sentry.io/](\u003chttps://docs.sentry.io/>)\n- [X] I am using the latest SDK release [https://github.com/getsentry/sentry-javascript/releases](\u003chttps://github.com/getsentry/sentry-javascript/releases>)\n\n### How do you use Sentry?\n\nSentry Saas ([sentry.io](\u003chttp://sentry.io>))\n\n### Which SDK are you using?\n\n@sentry/cloudflare\n\n### SDK Version\n\n10.53.1\n\n### Framework Version\n\nCloudflare Workers (Hono app, `withSentry` wrapper), scheduled handler via cron trigger\n\n### Link to Sentry event\n\n*(none — the failure mode is precisely that no event and no log is produced)*\n\n### Reproduction Example/SDK Setup\n\n```ts\nexport default Sentry.withSentry(\n  (env) => ({ dsn: env.SENTRY_DSN, release: env.RELEASE, tracesSampleRate: 0 }),\n  {\n    fetch: app.fetch,\n    scheduled: myScheduledHandler, // ← every tick reports outcome=exception\n  } satisfies ExportedHandler\u003cBindings>,\n);\n```\n\n### Steps to Reproduce\n\nWe could **not** build a minimal repro — `wrangler dev` and remote preview never exhibit it. It only manifested in the production isolate, with concurrent fetch traffic hitting the same Worker. Filing anyway because the code path is visible by inspection and our elimination evidence is strong; happy to run instrumented builds if it helps.\n\n1. Worker wrapped in `withSentry` with both `fetch` and `scheduled` handlers, cron trigger every minute.\n2. In production, every single cron tick reports `outcome: exception` in the Cloudflare dashboard and in `wrangler tail --format json`.\n3. Nothing is thrown from user code: no log lines, no Sentry event, no exception payload in the tail JSON — the handler body demonstrably runs to completion (its side effects are all applied).\n\n### Expected Result\n\nA failure inside the SDK's own post-handler flush must not fail the invocation. `wrapScheduledHandler` should never let its housekeeping reject the `waitUntil` promise:\n\n```js\n// instrumentations/worker/instrumentScheduled.js\n} finally {\n  waitUntil(flushAndDispose(client).catch(() => {\n    DEBUG_BUILD && debug.warn('Failed to flush/dispose in scheduled handler');\n  }));\n}\n```\n\n(Or make `flushAndDispose` itself never-reject — every wrapper call site passes it raw: `instrumentScheduled.js`, `instrumentQueue.js`, `instrumentEmail.js`, `instrumentTail.js`, and the five `waitUntil?.(flushAndDispose(client))` sites in `request.js`.)\n\n### Actual Result\n\nIn `@sentry/cloudflare@10.53.1`, `wrapScheduledHandler` does:\n\n```js\n} finally {\n  waitUntil(flushAndDispose(client));\n}\n```\n\nwith\n\n```js\nasync function flushAndDispose(client, timeout = 2000) {\n  ...\n  await client.flush(timeout);\n  client.dispose();\n}\n```\n\nOn Workers, a **rejected promise passed to** `ctx.waitUntil` **fails the whole invocation** — the runtime records `outcome: exception` even though the handler returned normally. For a fetch handler this is mostly invisible (the response already went out); for a **cron** it flips every tick to \"failed\" in the dashboard, silently: the rejection happens after user code, so nothing is loggable from the app and the SDK (whose transport just failed / whose client is mid-dispose) can't report its own demise.\n\n**Elimination evidence** from our production incident:\n\n* Every cron tick = `outcome: exception`, zero logs, zero exceptions in tail JSON, handler side effects all present.\n* Three consecutive releases added progressively more defensive guards **inside our handler** (whole-body try/catch, guarded resource teardown so nothing user-side could reject) — no effect whatsoever.\n* Moving `scheduled` **outside** `withSentry` (keeping our own direct envelope delivery for errors) fixed it instantly: same handler code, `outcome: ok` on every tick since, across weeks.\n\nWe did not manage to capture the underlying rejection value (by nature it never surfaces anywhere we can hook). Plausible candidates are `client.flush()` rejecting when the isolate's subrequest is canceled at teardown, or `dispose()` throwing on an already-disposed client under concurrent invocations sharing the isolate — possibly related to the client-lifetime issues in getsentry/sentry-javascript#20533 and getsentry/sentry-javascript#19589, but the failure mode here is different: the *invocation itself* is marked failed by the raw `waitUntil`.\n\nOur current workaround is keeping the scheduled handler unwrapped, which means losing `faas.cron` spans and automatic capture for crons — we'd love to re-wrap once the flush is guarded.","author":{"url":"https://github.com/aabrius","@type":"Person","name":"aabrius"},"datePublished":"2026-07-03T09:01:50Z","url":"https://github.com/getsentry/sentry-javascript/issues/21950"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fce9e042-66d8-9456-d76b-a6b94a8017f7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB354:D405E:344F5CD:4458C83:6B0433A4
html-safe-nonce5332c9709c3f4e7546acc08af33b6b74b6c085006b96b9feb79ae37260f41492
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzU0OkQ0MDVFOjM0NEY1Q0Q6NDQ1OEM4Mzo2QjA0MzNBNCIsInZpc2l0b3JfaWQiOiI1Njg4OTAxMDU5NzIxMDQ4OTk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca5bd77124a485f5740a040b1793eb02226590d8153c67fe0ebcc60a5741d909e
hovercard-subject-tagissue:4802049612
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/21950/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f4ccaa87d2b65119613460ab1a08d0aa0495a61fe7c6a6e2c169ce0155787fc4/getsentry/sentry-javascript/issues/21950
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f4ccaa87d2b65119613460ab1a08d0aa0495a61fe7c6a6e2c169ce0155787fc4/getsentry/sentry-javascript/issues/21950
og:image:altIs there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameaabrius
hostnamegithub.com
expected-hostnamegithub.com
Noneb7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3328572
octolytics-dimension-repository_nwogetsentry/sentry-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3328572
octolytics-dimension-repository_network_root_nwogetsentry/sentry-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec3dd496c3da6ea6b77e69c09279d2b81604654f1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-javascript/issues/21950#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F21950
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F21950
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-javascript
Reloadhttps://github.com/getsentry/sentry-javascript/issues/21950
Reloadhttps://github.com/getsentry/sentry-javascript/issues/21950
Reloadhttps://github.com/getsentry/sentry-javascript/issues/21950
getsentryhttps://github.com/getsentry
sentry-javascripthttps://github.com/getsentry/sentry-javascript
Codehttps://github.com/getsentry/sentry-javascript
Issues340 (340)https://github.com/getsentry/sentry-javascript/issues
Pull requests54 (54)https://github.com/getsentry/sentry-javascript/pulls
Discussionshttps://github.com/getsentry/sentry-javascript/discussions
Actionshttps://github.com/getsentry/sentry-javascript/actions
Security and quality7 (7)https://github.com/getsentry/sentry-javascript/security
Insightshttps://github.com/getsentry/sentry-javascript/insights
https://github.com/getsentry/sentry-javascript
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/21950
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/21950
#23151https://github.com/getsentry/sentry-javascript/pull/23151
[cloudflare] scheduled handler: raw waitUntil(flushAndDispose(client)) fails every cron invocation with silent outcome=exceptionhttps://github.com/getsentry/sentry-javascript/issues/21950#top
#23151https://github.com/getsentry/sentry-javascript/pull/23151
https://github.com/JPeer264
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Cloudflare Workershttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Cloudflare%20Workers%22
https://github.com/aabrius
aabriushttps://github.com/aabrius
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issue-4802049612
https://github.com/getsentry/sentry-javascript/issueshttps://github.com/getsentry/sentry-javascript/issues
https://docs.sentry.io/https://docs.sentry.io/
https://github.com/getsentry/sentry-javascript/releaseshttps://github.com/getsentry/sentry-javascript/releases
sentry.iohttp://sentry.io
#20533https://github.com/getsentry/sentry-javascript/issues/20533
#19589https://github.com/getsentry/sentry-javascript/issues/19589
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27520980586
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27520984811
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-4874563607
Linear Codehttps://linear.app
JS-2921https://linear.app/getsentry/issue/JS-2921
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950
github-actionshttps://github.com/apps/github-actions
Cloudflare Workershttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Cloudflare%20Workers%22
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27520984242
linear-codehttps://github.com/apps/linear-code
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27521009193
https://github.com/hiSandog
hiSandoghttps://github.com/hiSandog
on Jul 3, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-4874790243
JPeer264https://github.com/JPeer264
on Jul 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27593339524
https://github.com/JPeer264
JPeer264https://github.com/JPeer264
on Jul 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-4891208083
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Jul 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27599454886
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jul 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950
JPeer264https://github.com/JPeer264
on Jul 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-27605579655
fix(cloudflare): Catch potential errors during flush and dispose (#21976https://github.com/getsentry/sentry-javascript/commit/1bc2608e251af284c2594b456aa4300907da4e5f
#21976https://github.com/getsentry/sentry-javascript/pull/21976
1bc2608https://github.com/getsentry/sentry-javascript/commit/1bc2608e251af284c2594b456aa4300907da4e5f
s1gr1dhttps://github.com/s1gr1d
Waiting for: Communityhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Community%22
on Jul 15, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-28018260615
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jul 15, 2026https://github.com/getsentry/sentry-javascript/issues/21950
https://github.com/apps/getsantry
getsantryhttps://github.com/apps/getsantry
on Aug 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-5201437913
getsantryhttps://github.com/apps/getsantry
Stalehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Stale%22
on Aug 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-29052483931
JPeer264https://github.com/JPeer264
Waiting for: Communityhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Community%22
Stalehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Stale%22
on Aug 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-29056727284
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Aug 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950
https://github.com/JPeer264
JPeer264https://github.com/JPeer264
on Aug 6, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-5202651213
#23083https://github.com/getsentry/sentry-javascript/issues/23083
JPeer264https://github.com/JPeer264
completedhttps://github.com/getsentry/sentry-javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#23151https://github.com/getsentry/sentry-javascript/pull/23151
on Aug 25, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-29981622196
JPeer264https://github.com/JPeer264
on Aug 25, 2026https://github.com/getsentry/sentry-javascript/issues/21950#event-29981623260
feat(cloudflare): Add cacheClient to reuse the client across invocati…https://github.com/getsentry/sentry-javascript/commit/7c9971301a517dfae6c80346f93fcb1c4beef825
https://docs.github.com/articles/closing-issues-via-commit-messages
7c99713https://github.com/getsentry/sentry-javascript/commit/7c9971301a517dfae6c80346f93fcb1c4beef825
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Sep 23, 2026https://github.com/getsentry/sentry-javascript/issues/21950#issuecomment-5795080770
GitHub Actionshttps://help.github.com/en/actions
#23151https://github.com/getsentry/sentry-javascript/pull/23151
11.0.0 releasehttps://github.com/getsentry/sentry-javascript/releases/tag/11.0.0
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-javascript/issues/21950
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/21950
JPeer264https://github.com/JPeer264
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Cloudflare Workershttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Cloudflare%20Workers%22
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.