Title: @sentry/cloudflare: errors an Agent's RPC method catches are captured as unhandled when it calls an inherited Agent method · Issue #26673 · getsentry/sentry-javascript · GitHub
Open Graph Title: @sentry/cloudflare: errors an Agent's RPC method catches are captured as unhandled when it calls an inherited Agent method · Issue #26673 · getsentry/sentry-javascript
X Title: @sentry/cloudflare: errors an Agent's RPC method catches are captured as unhandled when it calls an inherited Agent method · Issue #26673 · 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/26673
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@sentry/cloudflare: errors an Agent's RPC method catches are captured as unhandled when it calls an inherited Agent method","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\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.15.0\n\n### Framework Version\n\nagents 0.33.0, wrangler 4.156.0, compatibility date 2026-09-17 with `nodejs_compat`\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\n`worker.js`, run with `wrangler dev`. It needs a Durable Object binding `C` (class `C`, SQLite) and any slow `text/event-stream` server on `127.0.0.1:8797`.\n\n```javascript\nimport * as Sentry from '@sentry/cloudflare';\nimport { Agent } from 'agents';\n\nconst opts = () => ({\n dsn: 'https://abc@o0.ingest.sentry.io/0',\n beforeSend(event) {\n console.log('captured', JSON.stringify(event.exception?.values?.[0]));\n return null;\n },\n});\n\nclass Conv extends Agent {\n aborts = new Set();\n\n async proxy() {\n const abort = new AbortController();\n this.aborts.add(abort);\n const response = await fetch('http://127.0.0.1:8797/', { signal: abort.signal });\n const [forwarded, metered] = response.body.tee();\n void this.keepAliveWhile(async () => {\n const reader = metered.getReader();\n for (;;) if ((await reader.read()).done) break;\n }).catch((error) => console.log('handled', String(error)));\n return new Response(forwarded);\n }\n\n async stop() {\n for (const abort of this.aborts) abort.abort();\n }\n}\n\nexport class C extends Sentry.instrumentAgentWithSentry(opts, Conv) {}\n\nexport default Sentry.withSentry(opts, {\n async fetch(request, env) {\n const stub = env.C.getByName('x');\n const response = await stub.proxy();\n const reader = response.body.getReader();\n await reader.read();\n setTimeout(() => stub.stop(), 300);\n try {\n for (;;) if ((await reader.read()).done) break;\n } catch {}\n return new Response('ok');\n },\n});\n```\n\n### Steps to Reproduce\n\n1. Start a server on `127.0.0.1:8797` that streams `text/event-stream` chunks slowly.\n2. Run the Worker above with `wrangler dev` and request `/`.\n3. `proxy()` is called over RPC and returns the upstream stream. `stop()` then aborts the upstream fetch, so the callback passed to the inherited `keepAliveWhile()` rejects with an `AbortError`, and `proxy()`'s `.catch` handles it.\n\n### Expected Result\n\nNothing is captured: the Agent catches the rejection itself.\n\n### Actual Result\n\nThe rejection is captured as unhandled before the Agent's own `.catch` runs:\n\n```\ncaptured {\"type\":\"AbortError\",\"value\":\"The operation was aborted\",\"mechanism\":{\"type\":\"auto.faas.cloudflare.durable_object\",\"handled\":false}}\nhandled AbortError: The operation was aborted\n```\n\nIn production the event has no stack frames, because the `AbortError` is created by the runtime's stream implementation.\n\n### Additional Context\n\nThe Agents SDK's `_autoWrapCustomMethods()` replaces the subclass's own methods on the prototype during construction. `instrumentAgentWithSentry` treats them as framework-managed and leaves them out of RPC instrumentation, so an incoming RPC call to `proxy()` runs on the default isolation scope. Inherited `Agent` methods such as `keepAliveWhile()` are not replaced, so they keep the RPC prototype wrapper. When `proxy()` calls one, `createRpcPrototypeWrapper` finds no trace metadata on the default isolation scope, treats the internal call as a new untraced RPC entry (`startNewTrace`), and captures its rejection as unhandled.\n\nThis looks like the failure fixed for constructor work in #24735 / #24829, reached here through framework-managed RPC entry points. One fix would be to give framework-managed methods an invocation scope when they are entered over RPC, without starting a span, so calls they make are not treated as new entries.\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>\n","author":{"url":"https://github.com/nwalters512","@type":"Person","name":"nwalters512"},"datePublished":"2026-11-19T22:13:16Z","url":"https://github.com/getsentry/sentry-javascript/issues/26673"}
| 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:3d01274c-871e-ff48-d7a7-5a0624976e8e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BD4:1425F4:39B545:50F604:6B043FD6 |
| html-safe-nonce | 006c8cded3577086a109d672155538067d1f813e2de60337a17f39305cf9444e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkQ0OjE0MjVGNDozOUI1NDU6NTBGNjA0OjZCMDQzRkQ2IiwidmlzaXRvcl9pZCI6IjUxNTI3Nzk0OTkyNTUxMTk4MzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d39ab52ac75905dd9530f6d4da3e3aa8dd43b48677a95b9bf6323b85592869f9 |
| hovercard-subject-tag | issue:6500116682 |
| 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/26673/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0f938e1b041a7e982218e35c7088ad334c69d4c45702f21640e94876d72cc70d/getsentry/sentry-javascript/issues/26673 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0f938e1b041a7e982218e35c7088ad334c69d4c45702f21640e94876d72cc70d/getsentry/sentry-javascript/issues/26673 |
| 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 | nwalters512 |
| 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