mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/websocket): pass on uncaught errors in idleTimeout (#21846)
Fixes https://github.com/denoland/deno/issues/21840 The problem was hard to reproduce as its a race condition. I've added a test that reproduces the problem 1/10 tries. We should move the idleTimeout handling to Rust (maybe even built into fastwebsocket).
This commit is contained in:
parent
19c10c0246
commit
6db631a432
3 changed files with 83 additions and 2 deletions
|
@ -502,12 +502,15 @@ class WebSocket extends EventTarget {
|
|||
clearTimeout(this[_idleTimeoutTimeout]);
|
||||
this[_idleTimeoutTimeout] = setTimeout(async () => {
|
||||
if (this[_readyState] === OPEN) {
|
||||
await op_ws_send_ping(this[_rid]);
|
||||
await PromisePrototypeCatch(op_ws_send_ping(this[_rid]), () => {});
|
||||
this[_idleTimeoutTimeout] = setTimeout(async () => {
|
||||
if (this[_readyState] === OPEN) {
|
||||
this[_readyState] = CLOSING;
|
||||
const reason = "No response from ping frame.";
|
||||
await op_ws_close(this[_rid], 1001, reason);
|
||||
await PromisePrototypeCatch(
|
||||
op_ws_close(this[_rid], 1001, reason),
|
||||
() => {},
|
||||
);
|
||||
this[_readyState] = CLOSED;
|
||||
|
||||
const errEvent = new ErrorEvent("error", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue