Skip to content

Commit

Permalink
fix(ext/websocket): WebSocketStream don't error with "sending after c…
Browse files Browse the repository at this point in the history
…losing" when closing (denoland#13134)
  • Loading branch information
crowlKats committed Dec 20, 2021
1 parent 0888ba7 commit ef95d7b
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions ext/websocket/02_websocketstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
const _url = Symbol("[[url]]");
const _connection = Symbol("[[connection]]");
const _closed = Symbol("[[closed]]");
const _closing = Symbol("[[closing]]");
const _earlyClose = Symbol("[[earlyClose]]");
class WebSocketStream {
[_rid];
Expand Down Expand Up @@ -260,26 +259,8 @@
}
case "closed":
case "close": {
if (this[_closing]) {
this[_closed].resolve(value);
core.tryClose(this[_rid]);
} else {
PromisePrototypeThen(
core.opAsync("op_ws_close", {
rid: this[_rid],
...value,
}),
() => {
this[_closed].resolve(value);
core.tryClose(this[_rid]);
},
(err) => {
this[_closed].reject(err);
controller.error(err);
core.tryClose(this[_rid]);
},
);
}
this[_closed].resolve(value);
core.tryClose(this[_rid]);
break;
}
case "error": {
Expand Down Expand Up @@ -330,7 +311,6 @@
}

[_earlyClose] = false;
[_closing] = false;
[_closed] = new Deferred();
get closed() {
webidl.assertBranded(this, WebSocketStream);
Expand Down Expand Up @@ -373,7 +353,6 @@
if (this[_connection].state === "pending") {
this[_earlyClose] = true;
} else if (this[_closed].state === "pending") {
this[_closing] = true;
PromisePrototypeCatch(
core.opAsync("op_ws_close", {
rid: this[_rid],
Expand Down

0 comments on commit ef95d7b

Please sign in to comment.