Uh oh!
There was an error while loading. Please reload this page.
fix(cloudflare): Instrument Durable Object handlers installed as read-only properties - #23759
Merged
Merged
Conversation
Contributor
size-limit report 📦
|
…-only properties
`agents` 0.22.0 installs the built-in Durable Object handlers on the instance with
`Object.defineProperty(instance, name, { value, configurable: true })`, which leaves
`writable` at `false`. The SDK replaced those handlers by assignment, so instrumenting
an Agent threw `Cannot assign to read only property 'webSocketMessage'` and every
request to the Agent failed with a 500.
Handlers are now installed through a helper that redefines a read-only property instead
of assigning to it, and that leaves the handler untouched when the property can be
neither assigned nor redefined.
`instrumentDurableObjectHandlers` moves into its own module, because the added helper
pushed `durableobject.ts` over the `max-lines` limit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>JPeer264force-pushed
the
jp/cloudflare-do-handler-writable
branch
from
August 31, 2026 09:41
efc4221 to
dd7ea05CompareUh oh!
There was an error while loading. Please reload this page.
…as read-only properties
andreiborza
approved these changes
Aug 31, 2026
JPeer264
enabled auto-merge (squash)
August 31, 2026 12:02
Uh oh!
There was an error while loading. Please reload this page.
JPeer264 added a commit
that referenced
this pull request
Aug 31, 2026
…read-only properties (#23769) Backport of: #23759 ## Differences to the original PR The fix itself (`setInstanceHandler`) and both new tests are identical to the original. The moved `instrumentDurableObjectHandlers` keeps v10's existing semantics, because v10 lacks the APIs `develop` uses: - `packages/cloudflare/src/instrumentations/instrumentDurableObjectHandlers.ts`: uses `wrapRequestHandler` from `../request` instead of `wrapRequestHandlerWithInit` + `init`, which do not exist on v10. - `packages/cloudflare/src/instrumentations/instrumentDurableObjectHandlers.ts`: `alarm` keeps `spanOp: 'function'` and the `webSocket*` handlers keep no `spanOp`, instead of the `FUNCTION` / `WEBSOCKET` constants from `@sentry/conventions/op`. v10 does not use those constants here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes#23758
agents0.22.0 installs the built-in Durable Object handlers on the instance withObject.defineProperty(instance, name, { value, configurable: true }), which leaveswritableatfalse. The SDK replaced those handlers by assignment, so instrumenting an Agent threwCannot assign to read only property 'webSocketMessage'and every request to the Agent failed with a 500.Handlers are now installed through a helper that redefines a read-only property instead of assigning to it, and that leaves the handler untouched when the property can be neither assigned nor redefined.
instrumentDurableObjectHandlersmoves into its own module, because the added helper pusheddurableobject.tsover themax-lineslimit.I also changed the E2E test to be
latestto catch that bug early on. Asagentsis in v0 the previous range,^0.20.0, would only stay within0.20.x.