-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More support for wasm #178
base: master
Are you sure you want to change the base?
Changes from 9 commits
68e6af1
e7d9517
2df83f9
3af9272
e09f999
88f1cc4
9539b5f
bac32e9
1a620f4
45ff7e3
b44ce75
4e8e9de
7856777
9d36a73
2d3497d
e4e0e06
d27cadf
aeeb3cc
77991b6
b9f7954
4efab3b
69aa772
bd9425a
d293552
4b13a9a
33aa079
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,12 @@ void fillRandomBytes(TypedData destination) { | |
subtle.getRandomValues(destination); | ||
} on subtle.JSDomException catch (e) { | ||
throw _translateDomException(e); | ||
} on Error catch (e) { | ||
final errorName = e.toString(); | ||
if (errorName != 'JavaScriptError') { | ||
rethrow; | ||
} | ||
|
||
throw _translateJavaScriptException(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not necessarily convinced this is a good idea. We don't want to catch errors that we're not supposed to catch. Hmm, I'm not sure exactly how we should handle this. I'm guessing it means that the I wonder if it's: I'm betting that we don't have good enough tests in this package for all the exception cases, hence, also why a lot of tests didn't start failing when Maybe, we need to put the error handling logic that differs into But I'm surprised that error handling differs between js and wasm, maybe we're doing something wrong 🤣 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for referencing dart-lang/sdk#55496 I'd suggest we look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would modify the code as follows 👍 } on Error catch (e) {
final errorName = e.toString();
if (errorName != 'JavaScriptError') {
rethrow;
}
throw _translateJavaScriptException(e);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a good idea, we probably have to do that in |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,13 @@ Object _translateDomException( | |
'"${e.name}", message: $message'); | ||
} | ||
|
||
Object _translateJavaScriptException(Error e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's give this a documentation comment. Let's link to the issue in the SDK, that way when we discover that the issue is resolved, we can work to fix this hack. |
||
// dart2wasm throws _JavaScriptError, but _JavaScriptError is not exposed. | ||
final errorMessage = e.toString(); | ||
final message = 'browser threw "$errorMessage"'; | ||
jonasfj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ArgumentError(message); | ||
jonasfj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// Handle instances of [subtle.JSDomException] specified in the | ||
/// [Web Cryptograpy specification][1]. | ||
/// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing behavior here?
Is this deliberate? If so should it not be orthogonal to this PR, and happen in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that when generating unsupported lists (e.g.
Uint64List
) in dart2js, an UnsupportedError is thrown. For example, the following test succeeds.The test fails in dart2wasm.
There is no JS class corresponding to
Uint64List
. Therefore, whenfillRandomBytes(Uint64List(32))
is called in dart2wasm, the process reaches this code.I changed it to UnsupportedError to keep the process consistent between dart2js and dart2wasm. It is possible to split a PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added test case. 4efab3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And restore previous code. The addition of the test makes it easier to understand the scope of the impact. bd9425a