Skip to content

Commit 5de6593

Browse files
committed
websocket: do not close when protocol supports it
This commit updates the WebSocket handler to not call ws.close() when stdin is closed but the ws protocol already supports closing (v5 protocol for example).
1 parent 47f1bf4 commit 5de6593

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/web-socket-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export class WebSocketHandler implements WebSocketInterface {
9696
buff.writeUint8(this.CloseStream, 0);
9797
buff.writeUint8(this.StdinStream, 1);
9898
ws.send(buff);
99+
return;
99100
}
100101
ws.close();
101102
});

src/web-socket-handler_test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ describe('V5 protocol support', () => {
404404
send: (data) => {
405405
sent = data;
406406
},
407-
close: () => {},
408-
} as WebSocket;
407+
close: () => {
408+
throw new Error('should not be called');
409+
},
410+
} as unknown as WebSocket;
409411
const stdinStream = new ReadableStreamBuffer();
410412
WebSocketHandler.handleStandardInput(ws, stdinStream);
411413
stdinStream.emit('end');

0 commit comments

Comments
 (0)