-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Open
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.
Description
Version
v17.0.1
Platform
any
Subsystem
No response
What steps will reproduce the bug?
import { readFile } from 'fs/promises';
const ref = new DOMException('The operation was aborted', 'AbortError');
console.log('REF INSTANCE', ref instanceof DOMException);
console.log('REF OBJECT', ref);
const ab = new AbortController();
ab.abort();
try {
await readFile('does_not_matter', { signal: ab.signal });
}
catch (err) {
console.log('ERR INSTANCE', err instanceof DOMException);
console.log('ERR OBJECT', err);
}
How often does it reproduce? Is there a required condition?
100%, including for all other native APIs that supports signals.
What is the expected behavior?
From the docs:
If a request is aborted the promise returned is rejected with an
AbortError
There is no mention that this is a non-standard new DOMException(message, 'AbortError')
error. As such, I expect 'REF' and 'ERR' logged objects to be the same (except the stack).
What do you see instead?
REF INSTANCE true
REF OBJECT DOMException [AbortError]: The operation was aborted
at file://<snip>/fail.mjs:3:13
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
ERR INSTANCE false
ERR OBJECT AbortError: The operation was aborted
at checkAborted (node:internal/fs/promises:373:11)
at readFile (node:internal/fs/promises:845:3)
at file://<snip>/fail.mjs:11:11
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:65:12) {
code: 'ABORT_ERR'
}
Additional information
This is only an issue in node 17+, since previous versions did not have a DOMException
global.
DerekNonGeneric, oskarlh, liuliangsir and n0isyDerekNonGeneric, liuliangsir and n0isy
Metadata
Metadata
Assignees
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.