mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
once pipe for process communication get bad, exit process immediately
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import { type Stream } from 'stream'
|
import { type Stream } from 'stream'
|
||||||
|
import { app } from 'electron'
|
||||||
const pipeSet = new WeakSet<Stream>()
|
const pipeSet = new WeakSet<Stream>()
|
||||||
|
|
||||||
export const pipeWriteRegardlessError = async (
|
export const pipeWriteRegardlessError = async (
|
||||||
@@ -10,8 +11,14 @@ export const pipeWriteRegardlessError = async (
|
|||||||
if (pipe && !pipeSet.has(pipe)) {
|
if (pipe && !pipeSet.has(pipe)) {
|
||||||
pipeSet.add(pipe)
|
pipeSet.add(pipe)
|
||||||
pipe.on('error', (error) => {
|
pipe.on('error', (error) => {
|
||||||
console.log('pipe.write Error', error)
|
void error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return pipe?.write(chunk, option, () => {})
|
return pipe?.write(chunk, option, (error) => {
|
||||||
|
if (error) {
|
||||||
|
console.log('pipe.write Error', error)
|
||||||
|
app.exit(1)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user