Skip to content

Commit e350b86

Browse files
pimterrylpinca
authored andcommitted
[fix] Do not unconditionally set the ready state to -2
If we're already closing, then we shouldn't move into the new -2 ready state (i.e. closing-because-the-remote-end-closed). We're already closing, we shouldn't go back to a state that allows sending another close frame.
1 parent 0c9705a commit e350b86

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/websocket.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ function socketOnEnd() {
940940
// the closing handshake but unlike `WebSocket.CLOSING` it does not prevent
941941
// `WebSocket.prototype.close()` from sending a close frame.
942942
//
943-
websocket._readyState = -2;
943+
if (websocket._readyState === WebSocket.OPEN) {
944+
websocket._readyState = -2;
945+
}
944946
websocket._receiver.end();
945947
}
946948

0 commit comments

Comments
 (0)