Skip to content

Commit 9e80c06

Browse files
committed
fix: don't pipe plugin output more than once at the time
1 parent d06afd6 commit 9e80c06

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/build/src/log/stream.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ const pushBuildCommandOutput = function (output: string, logsArray: string[]) {
4747
logsArray.push(output)
4848
}
4949

50+
const pipedPluginProcesses = new WeakMap<ChildProcess, ReturnType<typeof pipePluginOutput>>()
51+
5052
// Start plugin step output
5153
export const pipePluginOutput = function (childProcess: ChildProcess, logs: Logs, standardStreams: StandardStreams) {
52-
if (!logsAreBuffered(logs)) {
53-
return streamOutput(childProcess, standardStreams)
54+
if (pipedPluginProcesses.has(childProcess)) {
55+
return pipedPluginProcesses.get(childProcess)
5456
}
5557

56-
return pushOutputToLogs(childProcess, logs, standardStreams.outputFlusher)
58+
const listeners = !logsAreBuffered(logs)
59+
? streamOutput(childProcess, standardStreams)
60+
: pushOutputToLogs(childProcess, logs, standardStreams.outputFlusher)
61+
62+
pipedPluginProcesses.set(childProcess, listeners)
63+
64+
return listeners
5765
}
5866

5967
// Stop streaming/buffering plugin step output
@@ -71,6 +79,8 @@ export const unpipePluginOutput = async function (
7179
}
7280

7381
unpushOutputToLogs(childProcess, listeners.stdoutListener, listeners.stderrListener)
82+
83+
pipedPluginProcesses.delete(childProcess)
7484
}
7585

7686
// Usually, we stream stdout/stderr because it is more efficient

0 commit comments

Comments
 (0)