fix(companion): reject event waiters on unexpected socket close
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user