summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-06-25 06:39:02 -0700
committerGitHub <noreply@github.com>2024-06-25 19:09:02 +0530
commita1ff1a453c309c2f14c64ec31a3c43ef784781e2 (patch)
treee10c6c6e84e70d02adcefc54dd4dd2e9ccc60203 /ext/websocket/01_websocket.js
parent13aa1d70e905f1e1ec57d7eb57ad57d09d09deb2 (diff)
fix(ext/websocket): drop connection when close frame not ack (#24301)
Fixes #24292
Diffstat (limited to 'ext/websocket/01_websocket.js')
-rw-r--r--ext/websocket/01_websocket.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js
index afe543da5..60580a56c 100644
--- a/ext/websocket/01_websocket.js
+++ b/ext/websocket/01_websocket.js
@@ -424,6 +424,18 @@ class WebSocket extends EventTarget {
const rid = this[_rid];
while (this[_readyState] !== CLOSED) {
const kind = await op_ws_next_event(rid);
+ /* close the connection if read was cancelled, and we didn't get a close frame */
+ if (
+ (this[_readyState] == CLOSING) &&
+ kind <= 3 && this[_role] !== CLIENT
+ ) {
+ this[_readyState] = CLOSED;
+
+ const event = new CloseEvent("close");
+ this.dispatchEvent(event);
+ core.tryClose(rid);
+ break;
+ }
switch (kind) {
case 0: {