Title: [Cloudflare] instrumentWorkflowWithSentry does not capture errors thrown in run() outside a step · Issue #26286 · getsentry/sentry-javascript · GitHub
Open Graph Title: [Cloudflare] instrumentWorkflowWithSentry does not capture errors thrown in run() outside a step · Issue #26286 · getsentry/sentry-javascript
X Title: [Cloudflare] instrumentWorkflowWithSentry does not capture errors thrown in run() outside a step · Issue #26286 · 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/26286
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Cloudflare] instrumentWorkflowWithSentry does not capture errors thrown in run() outside a step","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\nRelated: #26091, #26161\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/cloudflare\n\n### SDK Version\n\n11.12.0 (the code is the same on `develop`)\n\n### Framework Version\n\nwrangler 4.156.0, compatibility_date 2026-05-01, compatibility_flags [\"nodejs_compat\"]\n\n### Reproduction Example/SDK Setup\n\n```ts\nimport * as Sentry from '@sentry/cloudflare'\nimport { WorkflowEntrypoint } from 'cloudflare:workers'\nimport { NonRetryableError } from 'cloudflare:workflows'\n\nclass MyWorkflow extends WorkflowEntrypoint\u003cEnv, Params> {\n async run(event, step) {\n if (!event.payload.accountId) {\n throw new NonRetryableError('accountId is required')\n }\n await step.do('load', { timeout: '1 second' }, async () => {\n // ...\n })\n }\n}\n\nexport const Instrumented = Sentry.instrumentWorkflowWithSentry(\n (env) => ({ dsn: env.SENTRY_DSN }),\n MyWorkflow,\n)\n```\n\n### Steps to Reproduce\n\n1. Wrap a Workflow with `instrumentWorkflowWithSentry`.\n2. Let `run()` fail outside a step callback, for example by throwing before the first step or by a step timeout.\n3. Trigger an instance.\n\n### Expected Result\n\nOne Sentry event for the error that fails the instance.\n\n### Actual Result\n\nNo event. The instance fails and the error is only in the Workers logs.\n\n`dev-packages/cloudflare-integration-tests` on `develop`, one instance per row, `retries.limit: 0` on steps:\n\n| `run()` fails with | Sentry events |\n|---|---|\n| `TypeError` thrown before any step | 0 |\n| `NonRetryableError` thrown before any step | 0 |\n| `Error` thrown after a successful step | 0 |\n| `step.waitForEvent` timeout | 0 |\n| `step.do` timeout (`Execution timed out after 1000ms`) | 0 |\n| `step.do` returning a non-serializable value (`Aborting engine: Value is not serialisable`) | 0 |\n| `Error` thrown inside the `step.do` callback | 1 |\n\nThe `run` proxy in `instrumentWorkflowWithSentry` wraps the call in `try { … } finally { waitUntil(flushAndDispose(client)) }` with no `catch`. Only `WrappedWorkflowStep.do` calls `captureException`, and only when the callback itself throws.\n\n### Additional Context\n\nCloudflare docs: \"Any error not handled at this top level will cause the Workflow instance to fail.\"\n\nA `catch` in the `run` proxy alone is not enough: `step.do` rejects with a copy of the error the callback threw, so the `__sentry_captured__` mark does not carry over and every failed step is reported twice. The fix tracks, per `step.do` call, whether the step callback already captured the error, and `run` skips only those rejections. Step timeouts and engine-side step failures are still reported once by `run`.\n\n### Contribution\n\nI have this fix ready with unit tests and integration tests covering the cases in the table above, and can open a PR once you give the go-ahead.\n","author":{"url":"https://github.com/DomWane","@type":"Person","name":"DomWane"},"datePublished":"2026-11-11T12:29:59Z","url":"https://github.com/getsentry/sentry-javascript/issues/26286"}
| 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:350fc484-263b-ce0e-a105-42157e966f4e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7FA:31EC7:3AF7D1:520D4E:6B043F86 |
| html-safe-nonce | 9a018e2ec44fd36def1a6326732178fe62dbe5ac356e46b17242e2dff139382c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0ZBOjMxRUM3OjNBRjdEMTo1MjBENEU6NkIwNDNGODYiLCJ2aXNpdG9yX2lkIjoiODk2NjY5NDY5MTI3ODE3NjEzNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4356f90c570110b1ca90904c81d4b5ff01402c391952472fec2b7a93821b0c8c |
| hovercard-subject-tag | issue:6328461781 |
| 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/26286/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f8499564442f44a5689d643c7e5c7430580c045f510baefa7d97c00aeb9f7bb7/getsentry/sentry-javascript/issues/26286 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f8499564442f44a5689d643c7e5c7430580c045f510baefa7d97c00aeb9f7bb7/getsentry/sentry-javascript/issues/26286 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DomWane |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| 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 | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| 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