Repository navigation
quic: fix edge cases where stream FIN would be lost #66759
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
Open
pimterry
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
pimterry:fix-stream-flush-flake
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−12
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
|
|
||
| // Test: a FIN that does not fit in the current packet is still sent. | ||
| // | ||
| // For a fixed body the final data and the FIN go out as separate STREAM | ||
| // frames, packed into the same packet where possible. When the data leaves | ||
| // only a few bytes free, the FIN-only frame does not fit and the packet is | ||
| // sent without it. The stream must then be retried, or the peer never sees | ||
| // the end of the stream. | ||
| // | ||
| // Which body size leaves too little room depends on per-packet overhead, so | ||
| // this sweeps sizes around one packet's payload, one stream at a time. | ||
|
|
||
| import { hasQuic, skip, mustCall } from '../common/index.mjs'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| if (!hasQuic) { | ||
| skip('QUIC is not enabled'); | ||
| } | ||
|
|
||
| const { listen, connect } = await import('../common/quic.mjs'); | ||
| const { bytes } = await import('stream/iter'); | ||
|
|
||
| const kMinSize = 1000; | ||
| const kMaxSize = 1300; | ||
| const kCount = kMaxSize - kMinSize + 1; | ||
|
|
||
| const received = []; | ||
| let next = Promise.withResolvers(); | ||
|
|
||
| const serverEndpoint = await listen(mustCall((serverSession) => { | ||
| serverSession.onstream = mustCall(async (stream) => { | ||
| const data = await bytes(stream); | ||
| received.push(data.byteLength); | ||
| next.resolve(); | ||
| }, kCount); | ||
| })); | ||
|
|
||
| const clientSession = await connect(serverEndpoint.address); | ||
| await clientSession.opened; | ||
| const closed = clientSession.closed.then(() => 'closed', () => 'closed'); | ||
|
|
||
| for (let size = kMinSize; size <= kMaxSize; size++) { | ||
| const stream = await clientSession.createUnidirectionalStream(); | ||
| stream.setBody(new Uint8Array(size)); | ||
| const result = await Promise.race([next.promise.then(() => 'ok'), closed]); | ||
| assert.strictEqual(result, 'ok', | ||
| `session closed before the FIN of a ${size}-byte ` + | ||
| 'stream arrived'); | ||
| next = Promise.withResolvers(); | ||
| assert.strictEqual(received.at(-1), size); | ||
| } | ||
|
|
||
| assert.strictEqual(received.length, kCount); | ||
|
|
||
| await clientSession.close(); | ||
| await serverEndpoint.close(); |
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.
Isn't this part still relevant?