From 24bcc32532a482fa8392d2f24e53af32b5bd07e8 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Fri, 11 Oct 2024 18:34:44 -0400 Subject: [PATCH] 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 --- server/src/plugin/runtime/child-process-worker.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/plugin/runtime/child-process-worker.ts b/server/src/plugin/runtime/child-process-worker.ts index dbc609185..457ff9de9 100644 --- a/server/src/plugin/runtime/child-process-worker.ts +++ b/server/src/plugin/runtime/child-process-worker.ts @@ -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() {