add error catcher for pipeForRead; remove the logic exit process on pipe error

This commit is contained in:
geekgeekrun
2024-03-24 19:47:34 +08:00
parent a28595da9a
commit 5ca62ade55
2 changed files with 3 additions and 3 deletions

View File

@@ -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') {

View File

@@ -1,6 +1,5 @@
import * as fs from 'fs'
import { type Stream } from 'stream'
import { app } from 'electron'
const pipeSet = new WeakSet<Stream>()
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)
}
})
}