summaryrefslogtreecommitdiff
path: root/ext/websocket/02_websocketstream.js
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-12-16 12:57:26 +0100
committerGitHub <noreply@github.com>2021-12-16 12:57:26 +0100
commit01a6b66034b53dbeffaa12d1d408066a1bc28643 (patch)
tree020291ed0b71562b6376bda2989925f105f6fadd /ext/websocket/02_websocketstream.js
parent9ffc7edc23444be8bdcc1befd3709b309780e3d1 (diff)
feat: support abort reasons in Deno APIs and `WebSocketStream` (#13066)
Diffstat (limited to 'ext/websocket/02_websocketstream.js')
-rw-r--r--ext/websocket/02_websocketstream.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js
index 246ddb1e3..dba22d557 100644
--- a/ext/websocket/02_websocketstream.js
+++ b/ext/websocket/02_websocketstream.js
@@ -125,10 +125,7 @@
if (options.signal?.aborted) {
core.close(cancelRid);
- const err = new DOMException(
- "This operation was aborted",
- "AbortError",
- );
+ const err = options.signal.reason;
this[_connection].reject(err);
this[_closed].reject(err);
} else {
@@ -313,7 +310,12 @@
}
},
(err) => {
- core.tryClose(cancelRid);
+ if (err instanceof core.Interrupted) {
+ // The signal was aborted.
+ err = options.signal.reason;
+ } else {
+ core.tryClose(cancelRid);
+ }
this[_connection].reject(err);
this[_closed].reject(err);
},