Skip to content

quic: get back to addressing some long standing quic updates#62387

Open
jasnell wants to merge 3 commits intonodejs:mainfrom
jasnell:jasnell/moar-quic-yay
Open

quic: get back to addressing some long standing quic updates#62387
jasnell wants to merge 3 commits intonodejs:mainfrom
jasnell:jasnell/moar-quic-yay

Conversation

@jasnell
Copy link
Copy Markdown
Member

@jasnell jasnell commented Mar 22, 2026

This is a large batch of improvements to the QUIC implementation covering
bug fixes, security hardening, stream data flow, HTTP/3 completeness,
and dead code cleanup.

Stream data flow:

  • Add streaming outbound support (InitStreaming, Write, EndWrite) on
    Stream using non-idempotent DataQueue inside Outbound
  • Write returns total buffered bytes for JS-side backpressure
  • Add inbound read wakeup via Blob::Reader setWakeup/NotifyPull to
    replace busy-polling on STATUS_BLOCK
  • Fix connection-level flow control: EntryRead now extends both
    per-stream and per-connection offsets
  • Track fin_sent state via new fin parameter on Stream::Commit
  • Track bytes_sent and max_offset_received stats
  • Remove unused PAUSED state field (pull model makes it unnecessary)
  • Add max_data_left() check in DefaultApplication::GetStreamData

HTTP/3:

  • Implement on_read_data_callback (critical: enables HTTP/3 body
    transmission via Bob protocol pull from Stream into nghttp3_vec)
  • Implement SetStreamPriority override for server-side priority
  • Implement OnShutdown (GOAWAY) with graceful session close

Security and TLS:

  • Fix use-after-release in TLS session ticket resumption by adding
    OSSLContext::set_session_ticket() method
  • Fix null UB in get_selected_alpn when no ALPN negotiated
  • Implement client cert verification with reject_unauthorized option
    (default true: reject during handshake; false: defer to JS)
  • Fix and re-enable server session ticket generation (root cause was
    invalid cast in GetAppDataSource: TLSSession* to AppData::Source*)
  • Implement early data / 0-RTT rejection handling
  • Add enable_early_data server option (default true)
  • Re-enable ngtcp2_crypto_ossl_init() (moved from static init to
    CreatePerContextProperties with std::call_once)

Bug fixes:

  • Fix AF_INET used instead of AF_INET6 in SelectPreferredAddress
  • Fix acked_at stat recorded in Commit instead of Acknowledge
  • Fix double destroyed_at timestamp in Endpoint::Destroy
  • Fix ShouldSetFin is_empty logic (return i == 0, not i > 0)
  • Fix token expiration clamping (std::min -> std::clamp with max)
  • Fix DCHECK_IMPLIES using = instead of == in token validation
  • Fix CID hash truncated to uint8_t (move mixing outside std::hash)
  • Fix PreferredAddress::AddressInfo string_view dangling pointer
  • Fix Endpoint::Send() stats counted after send failure
  • Fix Endpoint::OnReceive buffer leak on UV_UDP_PARTIAL and errors
  • Fix memcmp -> CRYPTO_memcmp for constant-time token comparison
  • Fix RegularToken memory info macros referencing RetryToken
  • Fix LogStream variable shadowing (EmitAlloc gets wrong size)
  • Fix [[unlikely]] annotation on common success path in Receive

New features:

  • Add on_receive_new_token handling: emits token + remote address
    to JS for storage and future reconnection
  • Add token field to Session::Options for client reconnection
  • Make 0-RTT retry conditional on validate_address option

Cleanup:

  • Remove dead declarations (Release, FastMarkBusy, FastRef)
  • Remove ShouldSetFin pure virtual (never called, FIN set directly)
  • Remove StreamData::remaining (write-only field)
  • Remove UnscheduleStream/Unschedule (ListNode dtor handles it)
  • Add static_assert for ngtcp2_vec/nghttp3_vec layout compatibility
  • Fix comment bugs (bidi->uni, retry->regular in RegularToken docs)
  • Make DebugIndentScope::indent_ thread_local
  • Clear server_state_ in Endpoint::Destroy
  • Add CreateEntryFromBuffer utility (detach-or-copy for ArrayBuffers)

@jasnell jasnell added the quic Issues and PRs related to the QUIC implementation / HTTP/3. label Mar 22, 2026
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 22, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 22, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.70%. Comparing base (7d1f1b4) to head (b9e92f4).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/node_blob.cc 38.46% 6 Missing and 2 partials ⚠️
lib/internal/blob.js 95.23% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #62387   +/-   ##
=======================================
  Coverage   89.70%   89.70%           
=======================================
  Files         678      678           
  Lines      207260   207289   +29     
  Branches    39749    39750    +1     
=======================================
+ Hits       185917   185951   +34     
- Misses      13443    13447    +4     
+ Partials     7900     7891    -9     
Files with missing lines Coverage Δ
lib/internal/quic/quic.js 100.00% <100.00%> (ø)
lib/internal/quic/state.js 51.73% <ø> (+0.10%) ⬆️
src/node_blob.h 37.50% <ø> (ø)
lib/internal/blob.js 99.43% <95.23%> (-0.57%) ⬇️
src/node_blob.cc 73.42% <38.46%> (-1.24%) ⬇️

... and 25 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.

@jasnell jasnell force-pushed the jasnell/moar-quic-yay branch from 50df771 to b85f58a Compare March 23, 2026 13:51
@jasnell jasnell requested a review from Qard March 27, 2026 03:24
jasnell added 3 commits March 27, 2026 11:23
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus 4.6
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus 4.6
@jasnell jasnell force-pushed the jasnell/moar-quic-yay branch from b85f58a to b9e92f4 Compare March 27, 2026 18:24
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@jasnell jasnell added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. quic Issues and PRs related to the QUIC implementation / HTTP/3.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants