Skip to content

Commit f909d80

Browse files
committed
fixup! lib: add abortSignal.throwIfAborted()
1 parent 02cc0ee commit f909d80

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/internal/abort_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class AbortSignal extends EventTarget {
9090
* @returns {AbortSignal}
9191
*/
9292
static abort(
93-
reason = new DOMException('This operation was aborted', 'AbortError')) {
93+
reason = new DOMException('This operation was aborted', 'AbortError')) {
9494
return createAbortSignal(true, reason);
9595
}
9696
}

test/parallel/test-abortcontroller.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,8 @@ const { ok, strictEqual, throws } = require('assert');
169169
{
170170
// Test abortSignal.throwIfAborted()
171171
throws(() => AbortSignal.abort().throwIfAborted(), { code: 20 });
172+
173+
// Does not throw because it's not aborted.
174+
const ac = new AbortController();
175+
ac.signal.throwIfAborted();
172176
}

0 commit comments

Comments
 (0)