Skip to content

stream: serialize concurrent share consumer reads#63478

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-share-serialize
Open

stream: serialize concurrent share consumer reads#63478
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-share-serialize

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 21, 2026

This updates stream/iter share() consumers to serialize overlapping
next() calls from the same async iterator, preserving call order when
multiple reads are started before earlier reads resolve.

A regression test was added for the reported case where two concurrent
next() calls returned second before first.

Fixes: #63477


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 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 89.65517% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.08%. Comparing base (d92ee51) to head (853f1a1).
⚠️ Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/streams/iter/share.js 89.65% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63478      +/-   ##
==========================================
+ Coverage   90.07%   90.08%   +0.01%     
==========================================
  Files         714      714              
  Lines      225944   225955      +11     
  Branches    42735    42742       +7     
==========================================
+ Hits       203520   203560      +40     
+ Misses      14205    14185      -20     
+ Partials     8219     8210       -9     
Files with missing lines Coverage Δ
lib/internal/streams/iter/share.js 84.35% <89.65%> (+0.23%) ⬆️

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

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 22, 2026
Ensure overlapping next() calls on a single share() consumer resolve
in the same order they were requested.

Fixes: nodejs#63477

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@trivikr trivikr force-pushed the stream-iter-share-serialize branch from 853f1a1 to 1d297dc Compare May 23, 2026 03:24
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: share() does not serialize overlapping next() calls on a consumer

2 participants