fix(desktop): suppress EPIPE errors in console transport (#25980)
This commit is contained in:
@@ -7,6 +7,7 @@ const TAIL_LINES = 1000
|
|||||||
|
|
||||||
export function initLogging() {
|
export function initLogging() {
|
||||||
log.transports.file.maxSize = 5 * 1024 * 1024
|
log.transports.file.maxSize = 5 * 1024 * 1024
|
||||||
|
initConsoleTransport()
|
||||||
cleanup()
|
cleanup()
|
||||||
return log
|
return log
|
||||||
}
|
}
|
||||||
@@ -38,3 +39,19 @@ function cleanup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initConsoleTransport() {
|
||||||
|
const write = log.transports.console.writeFn.bind(log.transports.console)
|
||||||
|
log.transports.console.writeFn = (options) => {
|
||||||
|
try {
|
||||||
|
write(options)
|
||||||
|
} catch (err) {
|
||||||
|
if (!isBrokenPipe(err)) throw err
|
||||||
|
log.transports.console.level = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBrokenPipe(err: unknown) {
|
||||||
|
return typeof err === "object" && err !== null && "code" in err && err.code === "EPIPE"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user