fix(companion): reject event waiters on unexpected socket close

This commit is contained in:
William Valentin
2026-02-16 19:42:23 -08:00
parent 61533bd816
commit 8837843df1
4 changed files with 61 additions and 2 deletions
+7 -1
View File
@@ -330,7 +330,13 @@ export class CompanionRuntimeClient {
settled = true;
this.ws = ws;
this.ws.on('message', (raw) => this.handleMessage(raw.toString()));
this.ws.on('close', () => this.rejectAllPending(new Error('WebSocket closed')));
this.ws.on('close', () => {
if (this.ws === ws) {
this.ws = null;
}
this.rejectAllPending(new Error('WebSocket closed'));
this.rejectEventWaits(new Error('WebSocket closed'));
});
this.ws.on('error', () => {
// close event handles pending rejection
});