spec icon indicating copy to clipboard operation
spec copied to clipboard

Should Error.isError return true for WebAssembly.Exception objects?

Open Ms2ger opened this issue 7 months ago • 4 comments

Ref https://github.com/tc39/proposal-is-error/issues/20

Ms2ger avatar Jun 03 '25 08:06 Ms2ger

Yes, it should.

ljharb avatar Jun 03 '25 14:06 ljharb

WebAssembly.Exception objects intentionally don't inherit from Error (https://github.com/WebAssembly/exception-handling/issues/183). I'm not familiar with the isError proposal, but from skimming it, that seems like it should mean that we should return false for WebAssembly.Exception objects.

eqrion avatar Jun 10 '25 14:06 eqrion

It doesn’t have to inherit from Error to return true, but if the reasoning is so they don’t have stack traces, and assuming they don’t have special structuredClone serialization behavior, then the predicate should probably return false for them, yes.

ljharb avatar Jun 10 '25 14:06 ljharb

Yes, the main reason is to avoid requiring stack traces (although they can have them if the JS constructor is used with a flag [1]). They also are not structured cloneable.

[1] https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md#api-additions

eqrion avatar Jun 10 '25 14:06 eqrion

It sounds like the consensus then is for Error.isError to return false for WA.Exception. It also sounds like that's the default behavior unless we added an [[ErrorData]] slot. So I think this should be closed (I don't have permissions).

eqrion avatar Oct 02 '25 16:10 eqrion