🐛 Fix: sync with picgo, suppress epiep error

This commit is contained in:
萌萌哒赫萝 2023-04-15 22:15:20 +08:00
parent d5f7121a3f
commit dc1458ffef
4 changed files with 30 additions and 2 deletions

View File

@ -54,6 +54,7 @@
"dexie": "^3.2.3",
"electron-updater": "^5.3.0",
"element-plus": "^2.2.32",
"epipebomb": "^1.0.0",
"fast-xml-parser": "^4.1.1",
"form-data": "^4.0.0",
"fs-extra": "^11.1.0",

View File

@ -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()

View File

@ -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
}

View File

@ -6829,6 +6829,11 @@ env-paths@^2.2.0:
resolved "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
epipebomb@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/epipebomb/-/epipebomb-1.0.0.tgz#57d1deda1d6bc81622b118a75fe6b5a7d34f6d88"
integrity sha512-NGv0bGlgetsi6ad5BuG1Pa9zpLLCeXeIa6wFGc+l0Emhr5rUlW8Rjx96NONlXZl4tMMaEODszyyy1A8ENjFoKA==
error-ex@^1.3.1:
version "1.3.2"
resolved "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"