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: pre-aborted pipeTo now applies dest failure handling
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 dc181502d8b7ad3b042912d88ee34e16aa9ffcfa

There are no files selected for viewing

3 changes: 2 additions & 1 deletion 3 doc/api/stream_iter.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ added:
* `...transforms` {Function|Object} Zero or more transforms to apply.
* `writer` {Object} Destination with `write(chunk)` method.
* `options` {Object}
* `signal` {AbortSignal} Abort the pipeline.
* `signal` {AbortSignal} Abort the pipeline. Aborting fails the destination
writer unless `preventFail` is `true`.
* `preventClose` {boolean} If `true`, do not call `writer.end()` when
the source ends. **Default:** `false`.
* `preventFail` {boolean} If `true`, do not call `writer.fail()` on
Expand Down
18 changes: 13 additions & 5 deletions 18 lib/internal/streams/iter/pull.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,18 @@ async function pipeTo(source, ...args) {

const signal = options?.signal;

// Check for abort
signal?.throwIfAborted();
function failWriter(error) {
if (!options?.preventFail) {
writer.fail?.(wrapError(error));
}
}

try {
signal?.throwIfAborted();
} catch (error) {
failWriter(error);
throw error;
}

const hasWriteSync = typeof writer.writeSync === 'function';
const useSyncIterableFastPath =
Expand Down Expand Up @@ -1192,9 +1202,7 @@ async function pipeTo(source, ...args) {
}
}
} catch (error) {
if (!options?.preventFail) {
writer.fail?.(wrapError(error));
}
failWriter(error);
throw error;
}

Expand Down
47 changes: 47 additions & 0 deletions 47 test/parallel/test-stream-iter-pipeto-signal.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,51 @@ const assert = require('assert');
const { setTimeout } = require('timers/promises');
const { pipeTo, from } = require('stream/iter');

async function testPipeToPreAbortedSignalFailsWriter() {
const reason = new Error('already aborted');
let sourceTouched = false;
const source = {
[Symbol.asyncIterator]() {
sourceTouched = true;
return {};
},
};
const writer = {
write: common.mustNotCall(),
fail: common.mustCall((error) => assert.strictEqual(error, reason)),
};

await assert.rejects(
pipeTo(source, writer, { signal: AbortSignal.abort(reason) }),
(error) => error === reason,
);
assert.strictEqual(sourceTouched, false);
}

async function testPipeToPreAbortedSignalPreventFail() {
const reason = new Error('already aborted');
let sourceTouched = false;
const source = {
[Symbol.asyncIterator]() {
sourceTouched = true;
return {};
},
};
const writer = {
write: common.mustNotCall(),
fail: common.mustNotCall(),
};

await assert.rejects(
pipeTo(source, writer, {
signal: AbortSignal.abort(reason),
preventFail: true,
}),
(error) => error === reason,
);
assert.strictEqual(sourceTouched, false);
}

// pipeTo with live signal, no transforms — abort mid-stream
async function testPipeToLiveSignalNoTransforms() {
const ac = new AbortController();
Expand Down Expand Up @@ -116,6 +161,8 @@ async function testPipeToLiveSignalWithTransformsCompletes() {
}

Promise.all([
testPipeToPreAbortedSignalFailsWriter(),
testPipeToPreAbortedSignalPreventFail(),
testPipeToLiveSignalNoTransforms(),
testPipeToLiveSignalNoTransformsPendingNext(),
testPipeToLiveSignalWithTransforms(),
Expand Down
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.