mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-25 18:20:24 +08:00
🐛 Fix: sync with picgo, suppress epiep error
This commit is contained in:
@@ -9,7 +9,7 @@ const logger = getLogger(LOG_PATH, 'PicList')
|
||||
// since the error may occur in picgo-core
|
||||
// so we can't use the log from picgo
|
||||
|
||||
const handleProcessError = (error: Error) => {
|
||||
const handleProcessError = (error: Error | string) => {
|
||||
logger('error', error)
|
||||
}
|
||||
|
||||
@@ -20,3 +20,21 @@ process.on('uncaughtException', error => {
|
||||
process.on('unhandledRejection', (error: any) => {
|
||||
handleProcessError(error)
|
||||
})
|
||||
|
||||
// acconrding to https://github.com/Molunerfinn/PicGo/commit/7363be798cfef11e980934e542817ff1d6c04389#diff-896d0db4fbd446798fbffec14d456b4cd98d4c72c46856c770a585fa7ab0926f
|
||||
function bootstrapEPIPESuppression () {
|
||||
let suppressing = false
|
||||
function logEPIPEErrorOnce () {
|
||||
if (suppressing) {
|
||||
return
|
||||
}
|
||||
|
||||
suppressing = true
|
||||
handleProcessError('Detected EPIPE error; suppressing further EPIPE errors')
|
||||
}
|
||||
|
||||
require('epipebomb')(process.stdout, logEPIPEErrorOnce)
|
||||
require('epipebomb')(process.stderr, logEPIPEErrorOnce)
|
||||
}
|
||||
|
||||
bootstrapEPIPESuppression()
|
||||
|
||||
6
src/universal/types/global.d.ts
vendored
6
src/universal/types/global.d.ts
vendored
@@ -2,4 +2,8 @@
|
||||
// https://stackoverflow.com/questions/35074713/extending-typescript-global-object-in-node-js/44387594#44387594
|
||||
declare var PICGO_GUI_VERSION: string
|
||||
declare var PICGO_CORE_VERSION: string
|
||||
declare var notificationList: IAppNotification[]
|
||||
declare var notificationList: IAppNotification[]
|
||||
|
||||
declare module 'epipebomb' {
|
||||
export default function epipebomb(stream: NodeJS.Process['stdout'], callback: () => void): void
|
||||
}
|
||||
Reference in New Issue
Block a user