diff --git a/packages/ui/src/main/flow/utils/pipe.ts b/packages/ui/src/main/flow/utils/pipe.ts index 5dcadb0..6337a0a 100644 --- a/packages/ui/src/main/flow/utils/pipe.ts +++ b/packages/ui/src/main/flow/utils/pipe.ts @@ -1,17 +1,17 @@ import * as fs from 'fs' +import { type Stream } from 'stream' +const pipeSet = new WeakSet() export const pipeWriteRegardlessError = async ( pipe: fs.WriteStream | null, chunk: unknown, option? ) => { - return new Promise((resolve) => { - // debugger - pipe?.write(chunk, option, (error) => { - if (error) { - console.log('pipe.write Error', error) - } - resolve(undefined) + if (pipe && !pipeSet.has(pipe)) { + pipeSet.add(pipe) + pipe.on('error', (error) => { + console.log('pipe.write Error', error) }) - }) + } + return pipe?.write(chunk, option, () => {}) }