server: aggressively catch child process pipe errors (#1609)

* server: aggressively catch python child process pipe errors

* document error behavior

* move stdio error handling to setupWorker

* handle undefined stdio
This commit is contained in:
Brett Jia
2024-10-11 18:34:44 -04:00
committed by GitHub
parent 5856ad60dd
commit 24bcc32532

View File

@@ -19,6 +19,12 @@ export abstract class ChildProcessWorker extends EventEmitter implements Runtime
this.worker.on('disconnect', () => this.emit('error', new Error('disconnect')));
this.worker.on('exit', (code, signal) => this.emit('exit', code, signal));
this.worker.on('error', e => this.emit('error', e));
// aggressively catch errors
// ECONNRESET can be raised when the child process is killed
for (const stdio of this.worker.stdio || []) {
if (stdio)
stdio.on('error', e => this.emit('error', e));
}
}
get pid() {