diff --git a/lib/internal/streams/iter/pull.js b/lib/internal/streams/iter/pull.js index 95871e99037d58..1355911f1ff56e 100644 --- a/lib/internal/streams/iter/pull.js +++ b/lib/internal/streams/iter/pull.js @@ -794,11 +794,6 @@ function pull(source, ...args) { function pipeToSync(source, ...args) { const { transforms, writer, options } = parsePipeToArgs(args, 'writeSync'); - // Handle transform-writer - if (isTransformObject(writer)) { - ArrayPrototypePush(transforms, writer); - } - // Normalize source and create pipeline const normalized = fromSync(source); const pipeline = transforms.length > 0 ? @@ -852,11 +847,6 @@ async function pipeTo(source, ...args) { validateAbortSignal(options.signal, 'options.signal'); } - // Handle transform-writer - if (isTransformObject(writer)) { - ArrayPrototypePush(transforms, writer); - } - const signal = options?.signal; // Check for abort diff --git a/test/parallel/test-stream-iter-pipeto.js b/test/parallel/test-stream-iter-pipeto.js index bc6fa9d4984233..5d8b5088f54089 100644 --- a/test/parallel/test-stream-iter-pipeto.js +++ b/test/parallel/test-stream-iter-pipeto.js @@ -141,6 +141,31 @@ async function testPipeToSyncWithTransforms() { assert.strictEqual(chunks.join(''), 'HELLO'); } +async function testPipeToWriterTransformMethodIgnored() { + const chunks = []; + const writer = { + transform: common.mustNotCall(), + write(chunk) { chunks.push(new TextDecoder().decode(chunk)); }, + }; + + await pipeTo(from('hello'), writer); + assert.strictEqual(chunks.join(''), 'hello'); +} + +async function testPipeToSyncWriterTransformMethodIgnored() { + const chunks = []; + const writer = { + transform: common.mustNotCall(), + writeSync(chunk) { + chunks.push(new TextDecoder().decode(chunk)); + return true; + }, + }; + + pipeToSync(fromSync('hello'), writer); + assert.strictEqual(chunks.join(''), 'hello'); +} + // PipeTo with writev writer async function testPipeToWithWritevWriter() { const allChunks = []; @@ -301,6 +326,8 @@ Promise.all([ testPipeToWithSignal(), testPipeToWithTransforms(), testPipeToSyncWithTransforms(), + testPipeToWriterTransformMethodIgnored(), + testPipeToSyncWriterTransformMethodIgnored(), testPipeToWithWritevWriter(), testPipeToSyncFallback(), testPipeToPreventFail(),