mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-11 05:01:04 +00:00
fix(desktop): suppress EPIPE errors in console transport (#25980)
This commit is contained in:
parent
acca2e92dc
commit
754a1fb712
1 changed files with 17 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ const TAIL_LINES = 1000
|
|||
|
||||
export function initLogging() {
|
||||
log.transports.file.maxSize = 5 * 1024 * 1024
|
||||
initConsoleTransport()
|
||||
cleanup()
|
||||
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"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue