Repository navigation
fix(server): preserve main worker responses after request cancellation - #751
Open
luizfelmach wants to merge 1 commit into
Open
luizfelmach wants to merge 1 commit into
luizfelmach wants to merge 1 commit into
Conversation
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.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
When a user worker terminates during a request, its teardown can cancel the request token shared with the main worker. If cancellation happens before the server processes the main worker's response, the server discards that response and returns an empty
503withx-served-by: base/server.For example, a CPU-limit failure can produce an empty
503instead of the main worker's JSON error response. The result depends on the ordering of teardown and response delivery. Existing CPU-limit integration tests accept both outcomes.What is the new behavior?
The server preserves a response successfully returned by the main worker, including its status, headers, and body, even when the request token has already been cancelled. The cancellation-based
503fallback now applies only when obtaining the main worker's response also failed.Regression coverage includes:
503outcome.Additional context
The cancellation path was traced from
DenoRuntime::dropthrough the task inop_net_acceptto the shared request token. The fix changes the server's response selection; worker teardown remains active.Validation on the original
v1.76.2-based branch, before cherry-picking ontomain:examples/mainrecorded 208 empty503responses in 2,200 requests before the fix and none in 4,200 requests after it. These covered CPU, memory, wall-clock and exception failures, connection reuse, and runtime configuration variants.Temporary diagnostic instrumentation was removed. The cherry-pick onto
mainapplied without conflicts; the test suite has not been rerun on that base.