-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
quic: fix reader backpressure deadlock on idle connections #63950
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
nodejs-github-bot
merged 2 commits into
nodejs:main
from
pimterry:fix-blocked-backpressure
Jun 20, 2026
+64
−0
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,63 @@ | ||
| // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
|
|
||
| // Test: a sender blocked on flow control is resumed once the consumer | ||
| // starts reading. This confirms that we do flush MAX_STREAM_DATA | ||
| // frames as expected when the consumer reads. | ||
|
|
||
| import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs'; | ||
| import { setTimeout as delay } from 'node:timers/promises'; | ||
| import assert from 'node:assert'; | ||
|
|
||
| const { strictEqual, deepStrictEqual } = assert; | ||
|
|
||
| if (!hasQuic) { | ||
| skip('QUIC is not enabled'); | ||
| } | ||
|
|
||
| const { listen, connect } = await import('../common/quic.mjs'); | ||
| const { bytes } = await import('stream/iter'); | ||
|
|
||
| // Larger than the default 256 KB stream flow-control window: | ||
| const size = 1024 * 1024; | ||
| const expected = new Uint8Array(size); | ||
| for (let i = 0; i < size; i++) expected[i] = i & 0xff; | ||
|
|
||
| const senderBlocked = Promise.withResolvers(); | ||
| const done = Promise.withResolvers(); | ||
|
|
||
| const serverEndpoint = await listen(mustCall((serverSession) => { | ||
| serverSession.onstream = mustCall(async (stream) => { | ||
| stream.onblocked = mustCallAtLeast(() => senderBlocked.resolve(stream), 1); | ||
| stream.setBody(expected); | ||
| await stream.closed; | ||
| }); | ||
| })); | ||
|
|
||
| const clientSession = await connect(serverEndpoint.address); | ||
| await clientSession.opened; | ||
|
|
||
| // Write a byte to open the stream: | ||
| const stream = await clientSession.createBidirectionalStream(); | ||
| await stream.writer.write(new Uint8Array([1])); | ||
|
|
||
| // Wait until the sender has filled the window and blocked. | ||
| const serverStream = await senderBlocked.promise; | ||
|
|
||
| // Poll until everything has been acked, so the stream is fully idle: | ||
| while (serverStream.stats.maxOffsetAcknowledged !== serverStream.stats.bytesSent) { | ||
| await delay(1); | ||
| } | ||
|
|
||
| // Try to read: | ||
| const received = await bytes(stream); | ||
| strictEqual(received.byteLength, expected.byteLength); | ||
| deepStrictEqual(received, expected); | ||
|
|
||
| stream.writer.endSync(); | ||
| await stream.closed; | ||
| clientSession.close(); | ||
| done.resolve(); | ||
|
|
||
| await done.promise; | ||
| await clientSession.closed; | ||
|
pimterry marked this conversation as resolved.
Outdated
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.