summaryrefslogtreecommitdiff
path: root/ext/websocket/01_websocket.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-01-09 19:56:54 +0530
committerGitHub <noreply@github.com>2024-01-09 19:56:54 +0530
commit6db631a432ee916380b62770357adb46edd7c281 (patch)
tree7374d69b2f26bc66f82a81db069963b0c0b14e37 /ext/websocket/01_websocket.js
parent19c10c024623a227bc68b6606bc2f32d25030ab7 (diff)
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).
Diffstat (limited to 'ext/websocket/01_websocket.js')
-rw-r--r--ext/websocket/01_websocket.js7
1 files changed, 5 insertions, 2 deletions
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", {