node icon indicating copy to clipboard operation
node copied to clipboard

`DOMException` should have `[[ErrorData]]` internal slot

Open petamoriken opened this issue 1 year ago • 5 comments

Version

N/A

Platform

N/A

Subsystem

N/A

What steps will reproduce the bug?

This bug has not surfaced yet, but when V8 implements Error.isError, it should return true for DOMException.

Error.isError(new DOMException(1)) // => false, true expected

How often does it reproduce? Is there a required condition?

Not yet.

What is the expected behavior? Why is that the expected behavior?

Due to a change in Web IDL. https://github.com/whatwg/webidl/pull/1421

What do you see instead?

Not yet.

Additional information

This issue can be resolved by using Reflect.construct. https://github.com/denoland/deno/pull/27342

As a side effect, util.types.isNativeError will return true as well.

petamoriken avatar Jan 07 '25 07:01 petamoriken

A simple way to do this might be making https://github.com/nodejs/node/blob/062ae6f3cb52bc741e47bb54a292dc0325da6083/lib/internal/per_context/domexception.js#L51 extend Error.

ljharb avatar Jan 07 '25 07:01 ljharb

A simple way to do this might be making

node/lib/internal/per_context/domexception.js

extend Error.

I tried to implement inheriting Error in Deno, but it caused WPT fails.

Object.getPrototypeOf(DOMException) === Function.prototype; // true

https://github.com/web-platform-tests/wpt/blob/5799f5b24761cff805f20e5ec130bf3cb328e4ed/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js#L13-L15

petamoriken avatar Jan 07 '25 07:01 petamoriken

@petamoriken indeed you'd have to Object.setPrototypeOf(DOMException.prototype, Function.prototype) or something as well.

ljharb avatar Jan 07 '25 18:01 ljharb

V8 is updated to 13.6 with shipped Error.isError, this issue is not fixed, stable Node 24 is planned in some days.

zloirock avatar May 03 '25 09:05 zloirock

Related to https://github.com/nodejs/node/issues/40789

Amirali-Amirifar avatar May 03 '25 20:05 Amirali-Amirifar