Skip to content

quic: remove unused fin flag from blob reader wakeup - #65315

Open
trivenay wants to merge 1 commit into
nodejs:mainfrom
trivenay:quic-blob-remove-dead-fin
Open

quic: remove unused fin flag from blob reader wakeup#65315
trivenay wants to merge 1 commit into
nodejs:mainfrom
trivenay:quic-blob-remove-dead-fin

Conversation

@trivenay

Copy link
Copy Markdown
Contributor

Fixes the dead code identified in #64767.

The blob reader used by QUIC inbound streams has two separate channels. The pull channel is where the iterator asks for data and gets a real answer: a chunk, "blocked, nothing available yet", or "end of stream". The wakeup channel exists only to wake a parked iterator after a blocked pull so it pulls again — it carries no data and answers no question.

The wakeup additionally carried a boolean label saying whether it was triggered by end-of-stream. That label is dead information: whatever it says, the woken iterator does the same single thing — loop back and pull. If the stream has ended, that next pull returns end-of-stream by itself, because the receive queue was already capped when the FIN was processed. The pull channel is the source of truth for "am I done?"; the label was a second announcement of something the very next pull confirms anyway, and the branch consuming it (if (fin) continue; as the final statement of the loop) behaves identically to not existing.

This removes the label end to end while keeping the wakeup itself: the JS iterator no longer reads a value from the wakeup promise, the C++ notifier no longer constructs or passes the boolean, and the end-of-stream path still fires a (now unlabeled) wakeup. All actual FIN processing — recording the final size, capping the receive queue, the stream state flags — is untouched.

One consequence deserves reviewer attention. The notifier coalesces wakeups: once it has woken the iterator, further wakeups are suppressed until the iterator actually pulls. Previously, end-of-stream wakeups bypassed that suppression "just in case". With the label gone the bypass goes too, so end-of-stream wakeups now coalesce like any other. This cannot stall the iterator: the iterator only parks after a pull returned "blocked", every pull resets the suppression flag on entry, and only synchronous JavaScript runs between that pull and the park — so a parked iterator always has suppression clear, and the first wakeup after parking always gets through. The bypass only ever fired while the iterator was already awake and about to pull, where an extra wakeup changes nothing.

Changes:

  • lib/internal/blob.js — stop reading a value from the wakeup; delete the dead branch and its comment.
  • src/node_blob.cc, src/node_blob.hNotifyPull() loses its boolean parameter and JS-facing argument.
  • src/quic/streams.cc — the end-of-stream call site drops the argument.

No behavior change; no new test. Existing test/parallel/test-quic-* and test/parallel/test-blob* pass on the compiled binary.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/quic

@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 Aug 15, 2026
@jasnell

jasnell commented Aug 16, 2026

Copy link
Copy Markdown
Member

@trivenay ... this will need a rebase

The fin argument threaded from Blob::Reader::NotifyPull to the JS
blob reader iterator was dead: the only consumer, `if (fin) continue;`,
was the last statement in the loop and behaved identically to falling
through. End-of-stream is always discovered by the subsequent pull
returning EOS, never via the wakeup label. Remove the flag from the
JS iterator, NotifyPull's signature/argv, and the EndReadable call
site. The `!fin` coalescing bypass collapses safely because a parked
reader always has pull_pending_ == false, so the first wakeup after
parking always fires.

Refs: nodejs#64767
Signed-off-by: Naman Trivedi <trivenay@amazon.com>
@trivenay

trivenay commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main — thanks for the heads-up!

@trivenay
trivenay force-pushed the quic-blob-remove-dead-fin branch from 9a01ab0 to 9cbb5e4 Compare August 16, 2026 09:46
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.11%. Comparing base (ad7a5b8) to head (9cbb5e4).

Files with missing lines Patch % Lines
src/node_blob.cc 0.00% 3 Missing ⚠️
lib/internal/blob.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #65315   +/-   ##
=======================================
  Coverage   90.11%   90.11%           
=======================================
  Files         752      752           
  Lines      251569   251560    -9     
  Branches    47268    47278   +10     
=======================================
- Hits       226701   226698    -3     
+ Misses      16233    16213   -20     
- Partials     8635     8649   +14     
Files with missing lines Coverage Δ
src/node_blob.h 37.50% <ø> (ø)
lib/internal/blob.js 89.16% <0.00%> (+1.01%) ⬆️
src/node_blob.cc 72.89% <0.00%> (+0.19%) ⬆️

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

@trivenay

trivenay commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

The x86_64-darwin: with shared libraries failure is the test-common-wpt-backends — known flaky test, unrelated to this change. Thankfully there is already a fix in flight for it in #65320.

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants