From ba5c64bf4541f540880cf35facdb8c24666072eb Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 13 Aug 2020 20:59:51 +0200 Subject: [PATCH] quic: use AbortController with correct name/message On the web, `AbortError` is the error name, not the error message. Change the code to match that. PR-URL: https://github.com/nodejs/node/pull/34763 Reviewed-By: James M Snell Reviewed-By: Rich Trott --- lib/internal/quic/core.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/internal/quic/core.js b/lib/internal/quic/core.js index 11515ebf5fa476..037718b896e35c 100644 --- a/lib/internal/quic/core.js +++ b/lib/internal/quic/core.js @@ -253,10 +253,10 @@ let warnedVerifyHostnameIdentity = false; let DOMException; -const lazyDOMException = hideStackFrames((message) => { +const lazyDOMException = hideStackFrames((message, name) => { if (DOMException === undefined) DOMException = internalBinding('messaging').DOMException; - return new DOMException(message); + return new DOMException(message, name); }); assert(process.versions.ngtcp2 !== undefined); @@ -664,10 +664,10 @@ class QuicEndpoint { if (signal != null && !('aborted' in signal)) throw new ERR_INVALID_ARG_TYPE('options.signal', 'AbortSignal', signal); - // If an AbotSignal was passed in, check to make sure it is not already + // If an AbortSignal was passed in, check to make sure it is not already // aborted before we continue on to do any work. if (signal && signal.aborted) - throw new lazyDOMException('AbortError'); + throw new lazyDOMException('The operation was aborted', 'AbortError'); state.state = kSocketPending; @@ -685,7 +685,7 @@ class QuicEndpoint { // while we were waiting. if (signal && signal.aborted) { state.state = kSocketUnbound; - throw new lazyDOMException('AbortError'); + throw new lazyDOMException('The operation was aborted', 'AbortError'); } // From here on, any errors are fatal for the QuicEndpoint. Keep in @@ -1064,7 +1064,7 @@ class QuicSocket extends EventEmitter { // If an AbotSignal was passed in, check to make sure it is not already // aborted before we continue on to do any work. if (signal && signal.aborted) - throw new lazyDOMException('AbortError'); + throw new lazyDOMException('The operation was aborted', 'AbortError'); state.state = kSocketPending; @@ -1086,7 +1086,7 @@ class QuicSocket extends EventEmitter { // Some number of endpoints may have successfully bound, while // others have not if (signal && signal.aborted) - throw lazyDOMException('AbortError'); + throw lazyDOMException('The operation was aborted', 'AbortError'); state.state = kSocketBound;