[dart2wasm] JS errors can't be caught using an interop type #55481
Labels
area-dart2wasm
Issues for the dart2wasm compiler.
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
web-js-interop
Issues that impact all js interop
DDC and dart2js catch the JS error as it is a subtype of
interceptors.JavaScriptObject
(and therefore a subtype ofJSObject
). dart2wasm does not, as its implementation of JS errors is not a subtype ofJSObject
:sdk/sdk/lib/_internal/wasm/lib/errors_patch.dart
Line 40 in ad95bb6
JSValue
, but it's not clear if a Wasm instruction exists to convert the error to anexternref
that can then be boxed. Making this a subtype ofJSValue
also has the other issue that if we replacedJSObject
withJSString
, dart2wasm would catch the error (becauseJSString
is aJSValue
) whereas DDC and dart2js will not.For now, users should avoid catching JS errors using an interop type for consistency.
The text was updated successfully, but these errors were encountered: