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: second batch of stream/iter fixes by jasnell · Pull Request #65658 · nodejs/node

stream: second batch of stream/iter fixes #65658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jasnell wants to merge 12 commits into nodejs:main from jasnell:jasnell/stream-iter-fixes-2

Uh oh!

There was an error while loading. Please reload this page.

Closed

stream: second batch of stream/iter fixes #65658

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
9b34191
stream: canWrite and ondrain now reflect physical capacity
jasnell Aug 30, 2026
9f50e02
stream: ensure factory signals remain active through closing
jasnell Aug 30, 2026
14ba0d5
stream: ensure async dispoal after endSync awaits for drain
jasnell Aug 30, 2026
8f679be
stream: ensure pre-existing writes drain before EOF and end() waits
jasnell Aug 30, 2026
dc18150
stream: pre-aborted pipeTo now applies dest failure handling
jasnell Aug 30, 2026
2a39d91
stream: make pipeTo source normalization independent of Writer
jasnell Aug 30, 2026
2488293
stream: make consumer signals on longer alter source precedence
jasnell Aug 30, 2026
997df07
stream: apply source normalization once at call time
jasnell Aug 30, 2026
4d02084
stream: ensure from() observes returned rejecting promise correctly
jasnell Aug 30, 2026
091e3a1
stream: fix nested async flushing with infinite sources
jasnell Aug 30, 2026
3c3b4bb
stream: ensure that stateful transforms preserve this
jasnell Aug 30, 2026
9fcfe31
stream: use webidl validation semantics for args
jasnell Aug 30, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
stream: ensure async dispoal after endSync awaits for drain
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@jasnell
jasnell committed Sep 2, 2026
commit 14ba0d5925aadd85cf4af35074604dc0d8d66248

There are no files selected for viewing

6 changes: 6 additions & 0 deletions 6 doc/api/stream_iter.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ or errored, this is a no-op. Unlike `write()` and `end()`, `fail()` is
unconditionally synchronous because failing a writer is a pure state
transition with no async work to perform.

#### `writer[Symbol.asyncDispose]()`

If the writer is open, calls `writer.fail()`. If the writer is closing after
`end()` or `endSync()`, waits for buffered data to drain. If the writer is
already closed or errored, resolves immediately.

#### `writer.write(chunk[, options])`

* `chunk` {Uint8Array|string}
Expand Down
25 changes: 8 additions & 17 deletions 25 lib/internal/streams/iter/push.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,12 @@ class PushQueue {
return this.#writerState;
}

get pendingEndPromise() {
return this.#pendingEnd?.promise ?? null;
}

setPendingEnd(pending) {
this.#pendingEnd = pending;
getPendingEndPromise() {
if (this.#pendingEnd === null) {
const { promise, resolve, reject } = PromiseWithResolvers();
this.#pendingEnd = { __proto__: null, promise, resolve, reject };
}
return this.#pendingEnd.promise;
}

/**
Expand Down Expand Up @@ -691,15 +691,7 @@ class PushWriter {
return PromiseReject(this.#queue.error);
}
if (result === -3) {
// Closing: buffer has data, create deferred promise that resolves
// when consumer drains past the end sentinel
const pendingEndPromise = this.#queue.pendingEndPromise;
if (pendingEndPromise !== null) {
return raceEndWithSignal(pendingEndPromise, signal);
}
const { promise, resolve, reject } = PromiseWithResolvers();
this.#queue.setPendingEnd({ __proto__: null, promise, resolve, reject });
return raceEndWithSignal(promise, signal);
return raceEndWithSignal(this.#queue.getPendingEndPromise(), signal);
}
// >= 0: byte count (immediate close or idempotent)
return PromiseResolve(result);
Expand All @@ -719,8 +711,7 @@ class PushWriter {
[SymbolAsyncDispose]() {
const state = this.#queue.writerState;
if (state === 'closing') {
// Wait for graceful drain
return this.#queue.pendingEndPromise ?? PromiseResolve();
return this.#queue.getPendingEndPromise();
}
if (state === 'open') {
this.fail();
Expand Down
18 changes: 18 additions & 0 deletions 18 test/parallel/test-stream-iter-push-writer.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,23 @@ async function testAsyncDispose() {
}
}

async function testAsyncDisposeWaitsAfterEndSync() {
const { writer, readable } = push({ budget: 16384 });
writer.writeSync('hello');
assert.strictEqual(writer.endSync(), -1);

let disposed = false;
const disposal = writer[Symbol.asyncDispose]().then(() => {
disposed = true;
});
await Promise.resolve();
assert.strictEqual(disposed, false);

assert.strictEqual(await text(readable), 'hello');
await disposal;
assert.strictEqual(disposed, true);
}

async function testSyncDispose() {
const { writer, readable } = push({ budget: 16384 });
writer.writeSync('hello');
Expand Down Expand Up @@ -666,5 +683,6 @@ Promise.all([
testEndIdempotentWhenClosed(),
testEndRejectsWhenErrored(),
testAsyncDispose(),
testAsyncDisposeWaitsAfterEndSync(),
testSyncDispose(),
]).then(common.mustCall());
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — 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.