d9fbecf5a7
Move audio scrub/volume and brush drafts off root React ticks, coalesce overlay layout IPC, cache machine fingerprint and asset URLs, share one scene overlay host, and stop idle Pixi ticker. Also harden console against EPIPE on window load failures. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
818 B
TypeScript
27 lines
818 B
TypeScript
/**
|
||
* В Electron (особенно после рестарта в dev) stdout/stderr часто уже закрыты.
|
||
* Обычный `console.error` тогда даёт EPIPE и валит main process диалогом Uncaught Exception.
|
||
*/
|
||
|
||
function isBrokenPipe(err: unknown): boolean {
|
||
const code = (err as NodeJS.ErrnoException | undefined)?.code;
|
||
return code === 'EPIPE' || code === 'ERR_STREAM_DESTROYED';
|
||
}
|
||
|
||
export function installStdoutEpipeGuards(): void {
|
||
for (const stream of [process.stdout, process.stderr]) {
|
||
stream?.on('error', (err: NodeJS.ErrnoException) => {
|
||
if (isBrokenPipe(err)) return;
|
||
});
|
||
}
|
||
}
|
||
|
||
export function safeConsoleError(...args: unknown[]): void {
|
||
try {
|
||
console.error(...args);
|
||
} catch (err) {
|
||
if (isBrokenPipe(err)) return;
|
||
throw err;
|
||
}
|
||
}
|