From 6db631a432ee916380b62770357adb46edd7c281 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 9 Jan 2024 19:56:54 +0530 Subject: 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). --- ext/websocket/01_websocket.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext/websocket/01_websocket.js') diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js index fdcb0be99..a52996d8d 100644 --- a/ext/websocket/01_websocket.js +++ b/ext/websocket/01_websocket.js @@ -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", { -- cgit v1.2.3