From f909d808362178d5977b57c9baeb5454b835e12d Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 24 Nov 2021 08:16:09 -0800 Subject: [PATCH] fixup! lib: add abortSignal.throwIfAborted() --- lib/internal/abort_controller.js | 2 +- test/parallel/test-abortcontroller.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/internal/abort_controller.js b/lib/internal/abort_controller.js index 48df6f3331d16f..234cd88e365327 100644 --- a/lib/internal/abort_controller.js +++ b/lib/internal/abort_controller.js @@ -90,7 +90,7 @@ class AbortSignal extends EventTarget { * @returns {AbortSignal} */ static abort( - reason = new DOMException('This operation was aborted', 'AbortError')) { + reason = new DOMException('This operation was aborted', 'AbortError')) { return createAbortSignal(true, reason); } } diff --git a/test/parallel/test-abortcontroller.js b/test/parallel/test-abortcontroller.js index f60b78509b8eff..3dd3a01d9f96c9 100644 --- a/test/parallel/test-abortcontroller.js +++ b/test/parallel/test-abortcontroller.js @@ -169,4 +169,8 @@ const { ok, strictEqual, throws } = require('assert'); { // Test abortSignal.throwIfAborted() throws(() => AbortSignal.abort().throwIfAborted(), { code: 20 }); + + // Does not throw because it's not aborted. + const ac = new AbortController(); + ac.signal.throwIfAborted(); }