Skip to content
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

Using a browser API that returns Promise #44664

Open
jonasfj opened this issue Jan 14, 2021 · 4 comments
Open

Using a browser API that returns Promise #44664

jonasfj opened this issue Jan 14, 2021 · 4 comments
Labels
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

Comments

@jonasfj
Copy link
Member

jonasfj commented Jan 14, 2021

I've trying to use window.crypto.subtle.generateKey and got crypto_subtle.dart working on dartdevc and dart2js, but flutter run -d web-server --release is broken (I couldn't reproduce the issue with dart2js -O4).

If I use CryptoKey from dart:html, I can get it working on flutter run -d web-server --release, as well as flutter test --platform chrome, but not dart test -p chrome.

Minimal example with comments:
https://gist.github.com/jonasfj/30d7a41b57d1af9b84edb039f1912011

Context: google/webcrypto.dart#7

@jonasfj jonasfj added the web-js-interop Issues that impact all js interop label Jan 14, 2021
@devoncarew devoncarew added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jan 14, 2021
@sigmundch
Copy link
Member

Thanks for the bug report!

Indeed, there is an internal limitation that disallows us to use JS-interop on types that are already expose in dart:html (what we call "native" types). This is a tricky and brittle part of JS-interop today that we hope to improve it this year.

Short term, @srujzs is about to land a change that will check and report a compile-time error if we detect this issue. We can't always detect it, but in the example you showed above we would have.

@johnniwinther
Copy link
Member

I think I observed something similar trying to use Window.requestFileSystem. This is defined to return a Future<FileSystem> but however I tried to access it, I always ended of with a failure because the async system expected the value to be have a correct Dart type but instead was a native JavaScript object.

@sigmundch
Copy link
Member

@johnniwinther - I believe your issue with requestFIleSystem is due to #45036

@srujzs
Copy link
Contributor

srujzs commented Feb 24, 2021

Right, the symptoms seem identical to that issue.

Addressing the original issue though, you can still workaround this limitation (that won't break in unexpected ways) by using @anonymous classes for CryptoKey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

No branches or pull requests

5 participants