Skip to content

Don't throw from the fail-open KJ_DEFER in request() - #8670

Merged
git-bruh merged 1 commit into
mainfrom
pkhanna/fix-fail-open-null-outbound-fatal
Nov 19, 2026
Merged

git-bruh merged 1 commit into
mainfrom
pkhanna/fix-fail-open-null-outbound-fatal

Conversation

@git-bruh

Copy link
Copy Markdown
Member

When a fetch handler that called passThroughOnException() fails, WorkerEntrypoint::request() opens the fail-open channel inside a KJ_DEFER. That destructor runs while the handler's exception unwinds, so if opening the channel throws, the process terminates. A dynamic Worker with globalOutbound: null does exactly that: its null outbound throws "not permitted to access the internet" from startRequest().

Catch the failure and fail open to a WorkerInterface that rejects with it. The fail-open path then responds with a 500, the same as when the channel opens lazily and the request through it fails, as a channel to another process does.

When a fetch handler that called passThroughOnException() fails,
WorkerEntrypoint::request() opens the fail-open channel inside a
KJ_DEFER. That destructor runs while the handler's exception
unwinds, so if opening the channel throws, the process terminates.
A dynamic Worker with `globalOutbound: null` does exactly that: its
null outbound throws "not permitted to access the internet" from
startRequest().

Catch the failure and fail open to a WorkerInterface that rejects
with it. The fail-open path then responds with a 500, the same as
when the channel opens lazily and the request through it fails, as
a channel to another process does.
@git-bruh
git-bruh requested review from a team as code owners November 19, 2026 12:42

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — A small, targeted fix that stops a throw from a destructor from terminating the process, with a regression test. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

The KJ_TRY/KJ_CATCH around getSubrequestChannelNoChecks stops the KJ_DEFER destructor from throwing while the handler's exception unwinds. It falls back to the existing WorkerInterface::fromException helper, so the fail-open path responds with a 500. The new test in worker-loader-test.js covers a dynamic Worker with globalOutbound: null.


📝 Documentation: ✅ LGTM

The new code comment describes how the code behaves now and why the destructor must not throw.


Reviewed commit: 110a3351

@git-bruh
git-bruh enabled auto-merge November 19, 2026 12:52
@git-bruh
git-bruh merged commit 0fff0a9 into main Nov 19, 2026
23 checks passed
@git-bruh
git-bruh deleted the pkhanna/fix-fail-open-null-outbound-fatal branch November 19, 2026 13:03
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.

2 participants