Title: Cloudflare Workflow teardown can deadlock on instrumented waitUntil · Issue #23005 · getsentry/sentry-javascript · GitHub
Open Graph Title: Cloudflare Workflow teardown can deadlock on instrumented waitUntil · Issue #23005 · getsentry/sentry-javascript
X Title: Cloudflare Workflow teardown can deadlock on instrumented waitUntil · Issue #23005 · getsentry/sentry-javascript
Description: Environment @sentry/cloudflare 10.69.0 Cloudflare Workflows Problem instrumentWorkflowWithSentry captures context.waitUntil.bind(context) inside each run() call. init() instruments that same context. When Cloudflare reuses a Workflow ins...
Open Graph Description: Environment @sentry/cloudflare 10.69.0 Cloudflare Workflows Problem instrumentWorkflowWithSentry captures context.waitUntil.bind(context) inside each run() call. init() instruments that same contex...
X Description: Environment @sentry/cloudflare 10.69.0 Cloudflare Workflows Problem instrumentWorkflowWithSentry captures context.waitUntil.bind(context) inside each run() call. init() instruments that same contex...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23005
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cloudflare Workflow teardown can deadlock on instrumented waitUntil","articleBody":"### Environment\n\n- `@sentry/cloudflare` 10.69.0\n- Cloudflare Workflows\n\n### Problem\n\n`instrumentWorkflowWithSentry` captures `context.waitUntil.bind(context)` inside each `run()` call. `init()` instruments that same context. When Cloudflare reuses a Workflow instance, a later run can therefore capture Sentry’s flush-lock-aware `waitUntil` wrapper instead of the original function.\n\nAt the end of that run, the wrapper schedules `flushAndDispose(client)` through the captured function. This can register the teardown promise in the same flush lock that `client.flush()` is waiting to drain, so teardown never settles. In production this surfaced as `Worker code had hung` immediately after otherwise successful workflow completion.\n\nApplication work registered through the instrumented `waitUntil` should remain tracked; only Sentry’s own teardown must bypass its instrumentation.\n\n### Suggested fix\n\nCapture the original function before client initialization, matching the existing RPC wrapper:\n\n```ts\nconst waitUntil = getOriginalWaitUntil(context).bind(context);\nconst client = init({ ...options, ctx: context, enableDedupe: false });\n```\n\nThe CommonJS build can use the corresponding `flush.getOriginalWaitUntil(context)` export.\n\n### Regression shape\n\nA regression test can reuse one instrumented Workflow instance for two runs. During the second run, register controlled pending application work through the instrumented context, return successfully, then release that work and await both the application and teardown promises. With the current implementation the teardown promise remains pending; using `getOriginalWaitUntil` lets both settle while genuine workflow errors still propagate.","author":{"url":"https://github.com/matthew-gizmo","@type":"Person","name":"matthew-gizmo"},"datePublished":"2026-08-04T11:15:50Z","url":"https://github.com/getsentry/sentry-javascript/issues/23005"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7f084367-5d02-a96b-7967-7b3160d515e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB58:12379F:2D99:38A2:6B043103 |
| html-safe-nonce | e3c20c5c0415a5adb65be151c2158b2159d07ed50428cc51050347c851812286 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjU4OjEyMzc5RjoyRDk5OjM4QTI6NkIwNDMxMDMiLCJ2aXNpdG9yX2lkIjoiNDYyNzAwMDAyNTc0MzQ4NTQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5188d943271d3cbd8fd311f0da7e8ae1412b7184a0539856ba007880608a75f6 |
| hovercard-subject-tag | issue:5059803243 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23005/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e395e44b26a74f5842e1590a3a60591cded82598fe3570f07158c235587d2688/getsentry/sentry-javascript/issues/23005 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e395e44b26a74f5842e1590a3a60591cded82598fe3570f07158c235587d2688/getsentry/sentry-javascript/issues/23005 |
| og:image:alt | Environment @sentry/cloudflare 10.69.0 Cloudflare Workflows Problem instrumentWorkflowWithSentry captures context.waitUntil.bind(context) inside each run() call. init() instruments that same contex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matthew-gizmo |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width