From 9e80c066f188c67d1a13136e30704936eeba2002 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 4 Nov 2025 19:33:22 +0100 Subject: [PATCH 1/2] fix: don't pipe plugin output more than once at the time --- packages/build/src/log/stream.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/build/src/log/stream.ts b/packages/build/src/log/stream.ts index da79141fc1..3307e47b0c 100644 --- a/packages/build/src/log/stream.ts +++ b/packages/build/src/log/stream.ts @@ -47,13 +47,21 @@ const pushBuildCommandOutput = function (output: string, logsArray: string[]) { logsArray.push(output) } +const pipedPluginProcesses = new WeakMap>() + // Start plugin step output export const pipePluginOutput = function (childProcess: ChildProcess, logs: Logs, standardStreams: StandardStreams) { - if (!logsAreBuffered(logs)) { - return streamOutput(childProcess, standardStreams) + if (pipedPluginProcesses.has(childProcess)) { + return pipedPluginProcesses.get(childProcess) } - return pushOutputToLogs(childProcess, logs, standardStreams.outputFlusher) + const listeners = !logsAreBuffered(logs) + ? streamOutput(childProcess, standardStreams) + : pushOutputToLogs(childProcess, logs, standardStreams.outputFlusher) + + pipedPluginProcesses.set(childProcess, listeners) + + return listeners } // Stop streaming/buffering plugin step output @@ -71,6 +79,8 @@ export const unpipePluginOutput = async function ( } unpushOutputToLogs(childProcess, listeners.stdoutListener, listeners.stderrListener) + + pipedPluginProcesses.delete(childProcess) } // Usually, we stream stdout/stderr because it is more efficient From f829e1379ffe98a4ed243dc0637e106dc1ead3ae Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Tue, 4 Nov 2025 19:42:23 +0100 Subject: [PATCH 2/2] fix types --- packages/build/src/log/stream.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/build/src/log/stream.ts b/packages/build/src/log/stream.ts index 3307e47b0c..27b5163bd7 100644 --- a/packages/build/src/log/stream.ts +++ b/packages/build/src/log/stream.ts @@ -50,7 +50,11 @@ const pushBuildCommandOutput = function (output: string, logsArray: string[]) { const pipedPluginProcesses = new WeakMap>() // Start plugin step output -export const pipePluginOutput = function (childProcess: ChildProcess, logs: Logs, standardStreams: StandardStreams) { +export const pipePluginOutput = function ( + childProcess: ChildProcess, + logs: Logs, + standardStreams: StandardStreams, +): LogsListeners | undefined { if (pipedPluginProcesses.has(childProcess)) { return pipedPluginProcesses.get(childProcess) } @@ -84,7 +88,7 @@ export const unpipePluginOutput = async function ( } // Usually, we stream stdout/stderr because it is more efficient -const streamOutput = function (childProcess: ChildProcess, standardStreams: StandardStreams) { +const streamOutput = function (childProcess: ChildProcess, standardStreams: StandardStreams): undefined { childProcess.stdout?.pipe(standardStreams.stdout) childProcess.stderr?.pipe(standardStreams.stderr) }