-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(build): rename AnyResponse::resume_() callers to resume() #36072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The response promise resolves on
buf.includes("\r\n\r\n")(header terminator) but the test then assertsresp.toContain("ignored"), which is body content — if headers and body arrive in separatedataevents, the promise resolves with a headers-only snapshot and the body assertion fails spuriously. Resolve onbuf.includes("ignored")instead (or drop the body assertion, since theHTTP/1.1 200line already proves the resume path fired).Extended reasoning...
What the bug is
The
datahandler at line 3533 resolves the response promise as soon asbuf.includes("\r\n\r\n")— i.e., once the HTTP header terminator has been seen. But line 3543 then assertsexpect(resp).toContain("ignored"), which is the response body. The resolve condition does not cover everything that is asserted.The code path that triggers it
JS strings are immutable:
buf += drebindsbufto a new string, andresolve(buf)captures the string value at that instant. If the ~100-byte response is delivered as twodataevents — first the status line + headers ending in\r\n\r\n, then the 7-byteignoredbody — the first event satisfiesbuf.includes("\r\n\r\n")and resolves the promise with the headers-only snapshot. The second event appends to the closure-localbuf, but the promise is already settled (the secondresolve()is a no-op), and theclosefallback at line 3536 is likewise a no-op on a settled promise.respat line 3542 is then the headers-only string, andtoContain("ignored")fails.Why existing code doesn't prevent it
There is no framing that guarantees the body is present when the header terminator is seen. The
closehandler cannot rescue it because the promise has already resolved. Neighboring raw-socket tests in this file that assert on the body accumulate untilclose(e.g.,toEndWith("\r\n\r\nhey")after the socket closes) rather than resolving on the header terminator.Impact
REVIEW.md is explicit under Tests reviewers reject: "Buffer raw socket/stdout chunks to the protocol's framing before asserting." This is exactly the pattern that rule targets. In practice, uWS corks
new Response("ignored")into a single ~100-byte write and loopback almost always delivers it in one segment, so the flake probability is very low — but it is non-zero across platforms/ASAN/debug scheduling, and it violates a rule that has blocked merges.Step-by-step proof
HTTP/1.1 200 OK\r\nContent-Type: text/plain;charset=utf-8\r\nContent-Length: 7\r\n\r\nignoredin oneres.end().dataevent containing everything up through...\r\n\r\n(headers only).buf= headers;buf.includes("\r\n\r\n")→ true →resolve(buf)with headers only.dataevent with"ignored".buf += "ignored"rebinds the local;resolve(buf)on a settled promise is a no-op.const resp = await response→ headers-only string.expect(resp).toStartWith("HTTP/1.1 200 ")passes;expect(resp).toContain("ignored")fails.Fix
Change the resolve condition to match what is asserted:
Or drop line 3543 entirely — the
HTTP/1.1 200status line already provesdetach_response()'s resume fired (without it the client would never see any response), so the body assertion adds no coverage.