Skip to content

stream: fix overlapping broadcast next calls#63500

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-broadcast-next-pending
Open

stream: fix overlapping broadcast next calls#63500
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-broadcast-next-pending

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 23, 2026

broadcast() consumers could leave an earlier next() call pending forever
when another next() was called before data became available. The later call
overwrote the stored resolver, so the next write resolved the newer promise
instead of the older one.

This updates broadcast consumers to keep the first pending read intact. A
later overlapping next() now closes that consumer, while the original pending
read still receives the next chunk.

Fixes: #63499


Assisted-by: openai:gpt-5.5

Preserve the first pending broadcast consumer read when next() is
called again before data is available. The overlapping read now closes
the consumer without replacing the earlier resolver, allowing the
pending read to receive the next chunk.

Fixes: nodejs#63499

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels May 23, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.15%. Comparing base (8d3245e) to head (87668cb).

Files with missing lines Patch % Lines
lib/internal/streams/iter/broadcast.js 72.72% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #63500   +/-   ##
=======================================
  Coverage   90.14%   90.15%           
=======================================
  Files         718      718           
  Lines      227984   227995   +11     
  Branches    42835    42832    -3     
=======================================
+ Hits       205522   205550   +28     
+ Misses      14235    14232    -3     
+ Partials     8227     8213   -14     
Files with missing lines Coverage Δ
lib/internal/streams/iter/broadcast.js 85.06% <72.72%> (-0.17%) ⬇️

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

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. request-ci Add this label to start a Jenkins CI on a PR. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stream/iter: broadcast consumer can leave earlier next() pending after overlapping next() calls

2 participants