Skip to content

fix: observe constructor-time outbound interception rejection - #266

Open
tlq5l wants to merge 1 commit into
cloudflare:mainfrom
tlq5l:fix/catch-constructor-interception-rejection
Open

tlq5l wants to merge 1 commit into
cloudflare:mainfrom
tlq5l:fix/catch-constructor-interception-rejection

Conversation

@tlq5l

@tlq5l tlq5l commented Oct 21, 2026 •

Copy link
Copy Markdown

Fixes #259

Problem

When a Durable Object is constructed while its container is already running, the constructor starts outbound interception inside blockConcurrencyWhile and stores the promise in applyOutboundInterceptionPromise without anything awaiting it. If applyOutboundInterception() rejects, the rejection is unobserved and becomes an unhandledRejection that a subclass cannot catch.

Fix

Attach a .catch at the call site that logs the error. The stored promise stays rejected, and refreshOutboundInterception() still re-applies and awaits its own copy, so the start() and runtime-config paths keep surfacing the error to the caller.

I did not await it inside blockConcurrencyWhile: per the Durable Objects docs, a throw there terminates and resets the object, which would turn a degraded interception setup into a crash loop.

Adds a unit test in src/tests/ (mocked ctx, no Docker) and a patch changeset.

Testing

Tests: npx vitest run src/tests -> 35 passed; with the container.ts change stashed, the new test fails and vitest reports Unhandled Rejection: Error: intercept failed. Not run against wrangler dev or Docker.

@tlq5l
tlq5l requested a review from a team as a code owner October 21, 2026 20:10
@tlq5l

tlq5l commented Nov 8, 2026

Copy link
Copy Markdown
Author

Is there anything I should change to get this ready to merge? Happy to rebase or adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled rejection when the constructor-time applyOutboundInterception() fails (container already running)

1 participant