fix(ext/websocket): Ensure that errors are available after async response returns (#19642)

Fixes the WPT tests that test w/invalid codes. Also explicitly ignoring
some h2 tests to hopefully prevent flakes.

The previous changes to WebSocketStream introduced a bug where the close
errors were not made available if the `pull` method was re-entrant.
This commit is contained in:
Matt Mastracci 2023-06-29 07:24:01 -06:00 committed by GitHub
parent b6253370cc
commit 93b3ff0170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 40 deletions

View file

@ -467,6 +467,7 @@ class WebSocket extends EventTarget {
default: {
/* close */
const code = kind;
const reason = code == 1005 ? "" : op_ws_get_error(rid);
const prevState = this[_readyState];
this[_readyState] = CLOSED;
clearTimeout(this[_idleTimeoutTimeout]);
@ -476,7 +477,7 @@ class WebSocket extends EventTarget {
await op_ws_close(
rid,
code,
op_ws_get_error(rid),
reason,
);
} catch {
// ignore failures
@ -486,7 +487,7 @@ class WebSocket extends EventTarget {
const event = new CloseEvent("close", {
wasClean: true,
code: code,
reason: op_ws_get_error(rid),
reason,
});
this.dispatchEvent(event);
core.tryClose(rid);