Skip to content

Cloudflare: with the cached client, a failing transport makes a Durable Object's constructor throw #26972

In progress

Description

@webbertakken

Note: This issue was written by my clanker. While I try to verify its steps as much as possible, it might not be 100% correct.


Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

11.20.0

Framework Version

Cloudflare Workers (workerd)

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from '@sentry/cloudflare'

class Room {
  constructor(_ctx: DurableObjectState, _env: unknown) {}
  async alarm() {}
}

const options = (cacheClient: boolean) => (): Sentry.CloudflareOptions => ({
  dsn: 'https://public@o1.ingest.sentry.io/1',
  cacheClient,
  transport: () => {
    throw new Error('transport unavailable')
  },
})

const Cached = Sentry.instrumentDurableObjectWithSentry(options(true), Room)
new Cached(ctx, env) // throws: Error: transport unavailable

const PerInvocation = Sentry.instrumentDurableObjectWithSentry(options(false), Room)
const room = new PerInvocation(ctx, env) // constructs
await room.alarm() // throws: Error: transport unavailable

Steps to Reproduce

  1. Instrument a Durable Object class with instrumentDurableObjectWithSentry, keeping the default cached client.
  2. Give it a transport whose creation throws (any failure while the client is set up).
  3. Construct the object, as the runtime does on a wake.

Measured in workerd through @cloudflare/vitest-plugin, on 11.12.0 and 11.20.0.

Expected Result

A failure inside Sentry's own setup never fails the instrumented object: the object constructs and its handlers run without Sentry.

Actual Result

With the cached client, init() runs inside the object's construction, before the class's own constructor, so the constructor throws and the runtime cannot bring the object up.

cacheClient: true (default) cacheClient: false
Constructor throws constructs
First handler (never reached) throws

Additional Context

11.14 deprecated cacheClient and asked anyone setting cacheClient: false to say why. We set it on our Workers and Durable Objects and have moved to the cached client; this is the one gap that remained.

Our workaround: construct the class bare when the instrumented construction throws before the class's own constructor ran.

Activity

  1. linear-code commented on Nov 29, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 29, 2026
  3. andreiborza commented on Nov 30, 2026

    @andreiborza
    Member

    Hi @webbertakken, thanks for writing in. We'll take a look.

  4. self-assigned this
    on Nov 30, 2026
  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions