mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
gateway: don't crash the whole process on a dead connector stdin pipe
writeLine()'s killed check only reflects Node-side .kill() calls, so it can't catch the connector exiting on its own (e.g. the TS3 server drops it) and closing its stdin first. Writing to that closed pipe threw an unhandled EPIPE 'error' event, which Node treats as fatal - crashing the gateway and every other client's live session along with it. Listening for the error on child.stdin turns it into an isolated write failure. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
0428f80af8
commit
032969d16a
1 file changed
+9
@@ -268,6 +268,15 @@ export class Ts3Connection {
|
||||
if (this.options.privilegeKey) args.push("--privilege-key", this.options.privilegeKey);
|
||||
this.child = spawn(CONNECTOR_BIN, args);
|
||||
|
||||
// The connector can exit on its own (e.g. the TS3 server drops it) and close
|
||||
// its stdin pipe before writeLine()'s `this.child.killed` guard has any way
|
||||
// to know - killed only reflects Node-side .kill() calls. A write to that
|
||||
// closed pipe emits an unhandled 'error' (EPIPE) on the stream, which Node
|
||||
// treats as fatal and crashes the whole gateway process, killing every
|
||||
// other client's session too. Listening here turns it into a normal,
|
||||
// isolated write failure instead of a process-wide crash.
|
||||
this.child.stdin.on("error", () => {});
|
||||
|
||||
createInterface({ input: this.child.stdout }).on("line", (line) => {
|
||||
try {
|
||||
interface RawClientInfo {
|
||||
|
||||
Reference in new issue
Block a user