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
1
commit 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,6 +379,16 @@ class Http3ApplicationImpl final : public Session::Application { | |
| nghttp3_conn_unblock_stream(*this, stream->id()); | ||
| } | ||
|
|
||
| void ExtendMaxData(uint64_t max_data) override { | ||
| Debug(&session(), | ||
| "HTTP/3 application extending max data to %" PRIu64, | ||
| max_data); | ||
| for (auto& [id, stream] : session().streams()) { | ||
| stream->UpdateWriteDesiredSize(); // the stream might be blocked | ||
| // on js side, is unblock stream also required? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you looking for an answer to this in this PR or is this more of a follow up? |
||
| } | ||
| } | ||
|
|
||
| void CollectSessionTicketAppData( | ||
| SessionTicket::AppData* app_data) const override { | ||
| uint8_t buf[kSessionTicketAppDataSize]; | ||
|
|
||
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
76 changes: 76 additions & 0 deletions
76
test/parallel/test-quic-h3-maxdata-external-buffer-failure.mjs
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about a non-H3 test? |
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,76 @@ | ||
| // 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; | ||
| // eslint-disable-next-line no-unused-vars | ||
| 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); |
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.
Do you need to update the stream size here like you do in
http3.cc?