Workers errors: document cross-request promise cancellation#29797
Closed
lukevalenta wants to merge 1 commit into
Closed
Workers errors: document cross-request promise cancellation#29797lukevalenta wants to merge 1 commit into
lukevalenta wants to merge 1 commit into
Conversation
lukevalenta
requested review from
irvinebroque,
mikenomitch and
nevikashah
as code owners
April 13, 2026 13:43
lukevalenta
force-pushed
the
lvalenta/cross-request-promise-cancellation
branch
from
April 13, 2026 13:46
79b4cc4 to
dee8e55
Compare
Adds a new 'Cause 3' subsection under the 'script will never generate a response' error explaining cross-request promise cancellation — a common pitfall when using promise-based lazy initialization (e.g. OnceCell or getOrInit patterns) in global scope. - Describes the exact warning message logged to the console - Explains the root cause: Promises are owned by the request context that created them; awaiting a Promise from a different request context causes cancellation when that context ends - Shows a common problematic pattern: promise-based OnceCell/getOrInit in global scope where concurrent requests await each other's Promises - Shows the correct fix: synchronous check-then-set pattern where each request initializes independently without cross-request awaiting - Notes the no_handle_cross_request_promise_resolution compatibility flag as a suppression-only workaround (not a real fix)
lukevalenta
force-pushed
the
lvalenta/cross-request-promise-cancellation
branch
from
April 13, 2026 14:00
dee8e55 to
ccb2f58
Compare
Contributor
|
Hey there, we've marked this pull request as stale because there's no recent activity on it. This label helps us identify PRs that might need updates (or to be closed out by our team if no longer relevant). |
Oxyjun
approved these changes
Apr 28, 2026
Contributor
|
Hey there, we've closed out this pull request because it's been stale for a while and there's been no additional action on it. If these changes are still relevant, open a new pull request (or flag to us in a GitHub issue). |
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 free
to 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.
Summary
OnceCell.getOrInit()) in global scope. Includes the exact warning message, a problematic code example, and the recommended check-then-set fix pattern.Background
The cross-request promise cancellation behavior was discovered when diagnosing 500 errors in a Rust-based Worker that used
tokio::sync::OnceCell::get_or_try_initfor lazy initialization of a certificate pool. Concurrent cold-start requests would fail because request B awaited a Promise created by request A; when A's context ended, B's continuation was cancelled. The exact runtime warning is:This scenario is not currently covered in the errors docs. The existing "Cause 1: Unresolved Promises" section covers a different case (a Promise that is never resolved), and "Cannot perform I/O on behalf of a different request" covers sharing I/O objects — but neither addresses cross-request Promise awaiting.