From 5ca62ade5510094bb64e3d8c84a93d7db6d39eae Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Sun, 24 Mar 2024 19:47:34 +0800 Subject: [PATCH] add error catcher for pipeForRead; remove the logic exit process on pipe error --- .../src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts | 3 +++ packages/ui/src/main/flow/utils/pipe.ts | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts b/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts index f0db5f4..74adbaf 100644 --- a/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts +++ b/packages/ui/src/main/flow/GEEK_AUTO_START_CHAT_WITH_BOSS_MAIN/index.ts @@ -150,6 +150,9 @@ export const waitForProcessHandShakeAndRunAutoChat = () => { setSuicideTimer() const pipeForRead: fs.ReadStream = fs.createReadStream(null, { fd: 3 }) + pipeForRead.on('error', () => { + return + }) const pipeForReadWithJsonParser = pipeForRead.pipe(JSONStream.parse()) pipeForReadWithJsonParser?.on('data', function waitForCanRun(data) { if (data.type === 'GEEK_AUTO_START_CHAT_CAN_BE_RUN') { diff --git a/packages/ui/src/main/flow/utils/pipe.ts b/packages/ui/src/main/flow/utils/pipe.ts index d270be4..9e853d2 100644 --- a/packages/ui/src/main/flow/utils/pipe.ts +++ b/packages/ui/src/main/flow/utils/pipe.ts @@ -1,6 +1,5 @@ import * as fs from 'fs' import { type Stream } from 'stream' -import { app } from 'electron' const pipeSet = new WeakSet() export const pipeWriteRegardlessError = async ( @@ -17,8 +16,6 @@ export const pipeWriteRegardlessError = async ( return pipe?.write(chunk, option, (error) => { if (error) { console.log('pipe.write Error', error) - app.exit(1) - process.exit(1) } }) }