summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
diff options
context:
space:
mode:
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: {