fix(gateway): crash safety on screen-share input timeout + proper error serialization
Root cause of "langsung left": YouTube bot-block/403 on u_c1tRmj7E4 (live
stream, LOGIN_REQUIRED) made yt-dlp timeout in resolveInputWithRetry (12s).
The timeout handler did cleanup() (removing once() listeners) THEN
tee.destroy(new Error(...)) — the PassThrough emitted 'error' with NO
listener left → unhandled stream 'error' event → uncaughtException →
gracefulShutdown → bot left voice.
Fix:
- resolveInputWithRetry: tee.destroy() silently after cleanup (error carried
in the rejection only); add permanent no-op tee.on('error') safety.
- prepareStream: output.on('error') no-op so ffmpeg spawn failure before
playStream attaches a demux listener never crashes the gateway.
- bootstrap: serialize uncaughtException/ClientError/DB errors with
{err, errorMsg, stack} (pino only serializes the 'err' magic key — the old
{error: err} key printed {} so crashes were invisible).
This commit is contained in:
@@ -234,6 +234,10 @@ export function prepareStream(
|
||||
}
|
||||
}
|
||||
|
||||
// Safety: proc may error before playStream attaches a demux listener on
|
||||
// `output`. A no-op listener here prevents an unhandled 'error' event
|
||||
// on the PassThrough from crashing the gateway on ffmpeg spawn failure.
|
||||
output.on("error", () => {});
|
||||
proc.stdout?.pipe(output);
|
||||
proc.stderr?.on("data", () => {
|
||||
/* swallow ffmpeg stderr */
|
||||
|
||||
Reference in New Issue
Block a user