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(); }