Repository navigation
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/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/cloudflare
SDK Version
11.15.0
Framework Version
agents 0.33.0, wrangler 4.156.0, compatibility date 2026-09-17 with nodejs_compat
Link to Sentry event
No response
Reproduction Example/SDK Setup
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.
import * as Sentry from '@sentry/cloudflare';
import { Agent } from 'agents';
const opts = () => ({
dsn: 'https://abc@o0.ingest.sentry.io/0',
beforeSend(event) {
console.log('captured', JSON.stringify(event.exception?.values?.[0]));
return null;
},
});
class Conv extends Agent {
aborts = new Set();
async proxy() {
const abort = new AbortController();
this.aborts.add(abort);
const response = await fetch('http://127.0.0.1:8797/', { signal: abort.signal });
const [forwarded, metered] = response.body.tee();
void this.keepAliveWhile(async () => {
const reader = metered.getReader();
for (;;) if ((await reader.read()).done) break;
}).catch((error) => console.log('handled', String(error)));
return new Response(forwarded);
}
async stop() {
for (const abort of this.aborts) abort.abort();
}
}
export class C extends Sentry.instrumentAgentWithSentry(opts, Conv) {}
export default Sentry.withSentry(opts, {
async fetch(request, env) {
const stub = env.C.getByName('x');
const response = await stub.proxy();
const reader = response.body.getReader();
await reader.read();
setTimeout(() => stub.stop(), 300);
try {
for (;;) if ((await reader.read()).done) break;
} catch {}
return new Response('ok');
},
});Steps to Reproduce
- Start a server on
127.0.0.1:8797that streamstext/event-streamchunks slowly. - Run the Worker above with
wrangler devand request/. proxy()is called over RPC and returns the upstream stream.stop()then aborts the upstream fetch, so the callback passed to the inheritedkeepAliveWhile()rejects with anAbortError, andproxy()'s.catchhandles it.
Expected Result
Nothing is captured: the Agent catches the rejection itself.
Actual Result
The rejection is captured as unhandled before the Agent's own .catch runs:
captured {"type":"AbortError","value":"The operation was aborted","mechanism":{"type":"auto.faas.cloudflare.durable_object","handled":false}}
handled AbortError: The operation was aborted
In production the event has no stack frames, because the AbortError is created by the runtime's stream implementation.
Additional Context
The 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.
This 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.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Nov 19, 2026
JS-4133
andreiborza commentedon Nov 19, 2026
Hi Nathan, thanks for filing this. We'll look into it.