GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: settle pending broadcast reads on return · nodejs/node@fbed90b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams/iter
    • broadcast.js
  • test/parallel
    • test-stream-iter-broadcast-basic.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/iter/broadcast.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/iter/broadcast.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class BroadcastImpl {
165165

166166
function detach() {
167167
state.detached = true;
168+
state.resolve?.({ __proto__: null, done: true, value: undefined });
168169
state.resolve = null;
169170
state.reject = null;
170171
if (self.#deleteConsumer(state)) {
Collapse file

‎test/parallel/test-stream-iter-broadcast-basic.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-iter-broadcast-basic.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ async function testCancelWithReason() {
161161
assert.strictEqual(result.message, 'cancelled');
162162
}
163163

164+
async function testPendingNextSettlesAfterReturn() {
165+
const { broadcast: bc } = broadcast();
166+
const iter = bc.push()[Symbol.asyncIterator]();
167+
168+
const pendingNext = iter.next();
169+
await iter.return();
170+
171+
const result = await pendingNext;
172+
assert.strictEqual(result.done, true);
173+
assert.strictEqual(result.value, undefined);
174+
}
175+
164176
// =============================================================================
165177
// Writer fail detaches consumers
166178
// =============================================================================
@@ -254,6 +266,7 @@ Promise.all([
254266
testCancelWithoutReason(),
255267
testCancelWithReason(),
256268
testCancelWithFalsyReason(),
269+
testPendingNextSettlesAfterReturn(),
257270
testFailDetachesConsumers(),
258271
testWriterFailIdempotent(),
259272
testLateJoinerSeesBufferedData(),

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.