diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 97e10d94348ef5..176a9e417d802a 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -821,14 +821,11 @@ function hideInternalStackFrames(error) { // to make usage of the error in userland and readable-stream easier. // It is a regular error with `.code` and `.name`. class AbortError extends Error { - constructor(message = 'The operation was aborted', options = {}) { - if (options === null || typeof options !== 'object') { + constructor(message = 'The operation was aborted', options = undefined) { + if (options !== undefined && typeof options !== 'object') { throw new codes.ERR_INVALID_ARG_TYPE('options', 'Object', options); } - const { - cause, - } = options; - super(message, { cause }); + super(message, options); this.code = 'ABORT_ERR'; this.name = 'AbortError'; }