Skip to content

quic: create streams synchronously - #67749

Open
pimterry wants to merge 1 commit into
nodejs:mainfrom
pimterry:quic-sync-stream-creation
Open

pimterry wants to merge 1 commit into
nodejs:mainfrom
pimterry:quic-sync-stream-creation

Conversation

@pimterry

Copy link
Copy Markdown
Member

The QUIC API stream creation methods are async and return promises, but they never wait for anything. Discussed briefly in #65331 (comment).

The only situation where there's some actual async work anywhere is pending streams (blocked on flow control, or incomplete initial handshake). In that case we do return immediately today (promise resolves immediately) but just with stream.pending set to true.

That is correct imo: we do want to return immediately, because we want to allow queueing operations immediately without waiting for the stream to actually open, e.g. so you can start queueing up requests on streams straight away, without separately waiting for the handshake to complete.

In the case where you really want to wait for the stream to open before you use it, you just create the stream then use await stream.opened. This already works today.

Making this API async when it doesn't actually wait is confusing (suggests await will actually wait for opened somehow). It also adds an unnecessary promise & microtask for every stream, and similarly forces the calling code to be async, etc.

This PR drops that:

  • Drop async from the methods.
  • Remove unnecessary await from a large number of existing calls.
  • Updates waitUntilAvailable text, which implied the promise would wait for flow control (it didn't - it returns as pending).
  • Fix the swapped values for pending/now in the createStream debug message.
  • Documents the existing stream.pending

The alternative to all this is to make stream creation actually wait (at least in some cases). I don't see much upside though, and this approach roughly matches node:http2.

Signed-off-by: Tim Perry <pimterry@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/quic

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. quic Issues and PRs related to the QUIC transport implementation. labels Nov 24, 2026
@pimterry

Copy link
Copy Markdown
Member Author

cc @martenrichter

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (e7db489) to head (71feb8f).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67749      +/-   ##
==========================================
- Coverage   90.55%   90.52%   -0.04%     
==========================================
  Files         803      803              
  Lines      285111   285117       +6     
  Branches    55039    55022      -17     
==========================================
- Hits       258186   258103      -83     
- Misses      17080    17155      +75     
- Partials     9845     9859      +14     
Files with missing lines Coverage Δ
lib/internal/quic/quic.js 100.00% <100.00%> (ø)

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martenrichter

Copy link
Copy Markdown
Contributor

For me it is ok. Either way, it is possible to implement the W3C webstreams and waituntilavailable.

lgtm

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 24, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 24, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. quic Issues and PRs related to the QUIC transport implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ Proxy