Skip to content

Commit 9d2db70

Browse files
authored
stream: remove transform-writer handling in pipeTo
The pipeTo() and pipeToSync() argument parser already requires the destination argument to be a writer. Remove the later transform-writer handling so writer objects with a transform() method are treated only as destinations. Fixes: #63683 Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 PR-URL: #63684 Fixes: #63683 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent aa25a0a commit 9d2db70

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

lib/internal/streams/iter/pull.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,6 @@ function pull(source, ...args) {
946946
function pipeToSync(source, ...args) {
947947
const { transforms, writer, options } = parsePipeToArgs(args, 'writeSync');
948948

949-
// Handle transform-writer
950-
if (isTransformObject(writer)) {
951-
ArrayPrototypePush(transforms, writer);
952-
}
953-
954949
// Normalize source and create pipeline
955950
const normalized = fromSync(source);
956951
const pipeline = transforms.length > 0 ?
@@ -1017,11 +1012,6 @@ async function pipeTo(source, ...args) {
10171012
validateAbortSignal(options.signal, 'options.signal');
10181013
}
10191014

1020-
// Handle transform-writer
1021-
if (isTransformObject(writer)) {
1022-
ArrayPrototypePush(transforms, writer);
1023-
}
1024-
10251015
const signal = options?.signal;
10261016

10271017
// Check for abort

test/parallel/test-stream-iter-pipeto.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,31 @@ async function testPipeToSyncWithTransforms() {
141141
assert.strictEqual(chunks.join(''), 'HELLO');
142142
}
143143

144+
async function testPipeToWriterTransformMethodIgnored() {
145+
const chunks = [];
146+
const writer = {
147+
transform: common.mustNotCall(),
148+
write(chunk) { chunks.push(new TextDecoder().decode(chunk)); },
149+
};
150+
151+
await pipeTo(from('hello'), writer);
152+
assert.strictEqual(chunks.join(''), 'hello');
153+
}
154+
155+
async function testPipeToSyncWriterTransformMethodIgnored() {
156+
const chunks = [];
157+
const writer = {
158+
transform: common.mustNotCall(),
159+
writeSync(chunk) {
160+
chunks.push(new TextDecoder().decode(chunk));
161+
return true;
162+
},
163+
};
164+
165+
pipeToSync(fromSync('hello'), writer);
166+
assert.strictEqual(chunks.join(''), 'hello');
167+
}
168+
144169
// PipeTo with writev writer
145170
async function testPipeToWithWritevWriter() {
146171
const allChunks = [];
@@ -301,6 +326,8 @@ Promise.all([
301326
testPipeToWithSignal(),
302327
testPipeToWithTransforms(),
303328
testPipeToSyncWithTransforms(),
329+
testPipeToWriterTransformMethodIgnored(),
330+
testPipeToSyncWriterTransformMethodIgnored(),
304331
testPipeToWithWritevWriter(),
305332
testPipeToSyncFallback(),
306333
testPipeToPreventFail(),

0 commit comments

Comments
 (0)