Repository navigation
quic: update writedesiredsize on maxdataframe #65306
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
martenrichter
wants to merge
5
commits into
nodejs:main
Choose a base branch
from
martenrichter:callbackformaxdata
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6eba343
quic: update writedesiredsize on maxdataframe
martenrichter e695b56
quic: use updateWriteDesiredSize for MaxData
martenrichter 49cf145
quic: fix linting
martenrichter 625fc1a
quic: fix linting2
martenrichter d910b2d
quic: new lint rules
martenrichter 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
75 changes: 75 additions & 0 deletions
75
test/parallel/test-quic-h3-maxdata-external-buffer-failure.mjs
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,75 @@ | ||
| // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
|
|
||
| // Test: Quic maxdata updates on http/3 | ||
| // Client sends a body that precisely fills the session window size, | ||
| // and verifies that it is data transfer is not stalled. | ||
|
|
||
| import { hasQuic, skip } from '../common/index.mjs'; | ||
| import { readFile } from 'node:fs/promises'; | ||
| import { setTimeout as sleep } from 'node:timers/promises'; | ||
|
|
||
| if (!hasQuic) { | ||
| skip('QUIC is not enabled'); | ||
| } | ||
| const { listen, connect } = await import('node:quic'); | ||
| const { createPrivateKey } = await import('node:crypto'); | ||
| const { drainableProtocol } = await import('stream/iter'); | ||
|
|
||
| const keys = 'test/fixtures/keys'; | ||
| const key = createPrivateKey(await readFile(`${keys}/agent1-key.pem`)); | ||
| const cert = await readFile(`${keys}/agent1-cert.pem`); | ||
|
|
||
| const WINDOW = 4096; | ||
| // Fills the window exactly: | ||
| // considers all framing including some initial session capsules | ||
| const BODY = WINDOW - 38; | ||
|
|
||
| let letServerRead; | ||
| const serverMayRead = new Promise((resolve) => { letServerRead = resolve; }); | ||
|
|
||
| const endpoint = await listen((session) => { | ||
| session.onstream = async (stream) => { | ||
| await serverMayRead; | ||
| for await (const _ of stream) { /* reading extends the window */ } | ||
| }; | ||
| }, { | ||
| sni: { '*': { keys: [key], certs: [cert] } }, | ||
| transportParams: { | ||
| initialMaxStreamDataBidiRemote: 1024 * 1024, // Make sure maxstreamdata does not block | ||
| initialMaxData: WINDOW, | ||
| }, | ||
| onheaders() { this.sendHeaders({ ':status': '200' }); }, | ||
| }); | ||
|
|
||
| const session = await connect(endpoint.address, { | ||
| servername: 'localhost', | ||
| verifyPeer: 'manual', | ||
| }); | ||
| await session.opened; | ||
|
|
||
| // Budget well above the window, so the window is what stops the writer. | ||
| const stream = await session.createBidirectionalStream({ budget: 1024 * 1024 }); | ||
| stream.sendHeaders({ | ||
| ':method': 'POST', | ||
| ':path': '/', | ||
| ':scheme': 'https', | ||
| ':authority': 'localhost', | ||
| }, { terminal: false }); | ||
|
|
||
| const writer = stream.writer; | ||
| writer.writeSync(new Uint8Array(BODY)); | ||
|
|
||
| // Long enough for every byte to be acked. The peer acks as data arrives, | ||
| // whether or not its application has read any of it, so by now the window is | ||
| // exhausted, the send buffer is empty, and no further ACK can arrive. | ||
| await sleep(500); | ||
|
|
||
| const watchdog = setTimeout(() => { | ||
| console.error('STALLED: no drain after MAX_STREAM_DATA'); | ||
| process.exit(1); | ||
| }, 5000); | ||
| letServerRead(); // Extend the window, with no ack attached | ||
| await writer[drainableProtocol](); | ||
|
|
||
| clearTimeout(watchdog); | ||
| process.exit(0); |
51 changes: 51 additions & 0 deletions
51
test/parallel/test-quic-maxdata-external-buffer-failure.mjs
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,51 @@ | ||
| // Flags: --experimental-quic --experimental-stream-iter --no-warnings | ||
|
|
||
| // Test: Quic maxdata updates on raw quic | ||
| // Client sends a body that precisely fills the session window size, | ||
| // and verifies that it is data transfer is not stalled. | ||
|
|
||
| import { hasQuic, skip } from '../common/index.mjs'; | ||
| import * as assert from 'node:assert'; | ||
| import { readFileSync } from 'node:fs'; | ||
| import { setImmediate } from 'node:timers/promises'; | ||
|
|
||
|
|
||
| if (!hasQuic) { | ||
| skip('QUIC is not enabled'); | ||
| } | ||
| const { listen, connect } = await import('node:quic'); | ||
| const { createPrivateKey } = await import('node:crypto'); | ||
|
|
||
| const tls = { | ||
| keys: [createPrivateKey(readFileSync('test/fixtures/keys/agent1-key.pem'))], | ||
| certs: [readFileSync('test/fixtures/keys/agent1-cert.pem')], | ||
| }; | ||
| const WINDOW = 4096; | ||
| const serverRead = Promise.withResolvers(); | ||
|
|
||
| // Server: holds the data unread (so no MAX_DATA window updates) until told to read. | ||
| const endpoint = await listen((session) => { | ||
| session.onstream = async (stream) => { | ||
| await serverRead.promise; | ||
| for await (const _ of stream); | ||
| }; | ||
| }, { alpn: 'x', sni: { '*': tls }, transportParams: { initialMaxData: WINDOW } }); | ||
|
|
||
| const session = await connect(endpoint.address, { alpn: 'x', verifyPeer: 'manual' }); | ||
| const stream = session.createBidirectionalStream(); | ||
| const writer = stream.writer; | ||
|
|
||
| // Fill the connection window exactly. | ||
| writer.writeSync(new Uint8Array(WINDOW)); | ||
| // Wait for ack, so nothing is in flight. | ||
| while (stream.stats.maxOffsetAcknowledged < WINDOW) await setImmediate(); | ||
| console.log('window full, canWrite:', writer.canWrite); // false, as expected | ||
|
|
||
| // Server reads -> sends MAX_DATA -> window reopens. | ||
| serverRead.resolve(); | ||
| // Wait for the writer to drain, or give up after 1s if it never does. | ||
| await writer[Symbol.for('Stream.drainableProtocol')](); | ||
|
|
||
| // If the client handles MAX_DATA correctly, this should be true: | ||
| assert.ok(writer.canWrite, 'window should have reopened'); | ||
| process.exit(0); |
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.