Skip to content

Service Worker doesn't work because dart2js doesn't understand Promise #22862

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

Closed
DartBot opened this issue Mar 16, 2015 · 7 comments
Closed

Service Worker doesn't work because dart2js doesn't understand Promise #22862

DartBot opened this issue Mar 16, 2015 · 7 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html library-html-worker Issues related to Web Workers and Service Workers P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Mar 16, 2015

This issue was originally filed by [email protected]


What steps will reproduce the problem?

  1. download the attached zip file
  2. launch in dartium or chrome
  3. try to change the service worker file sw.js or sw.dart

What is the expected output? What do you see instead?

If you launch in dartium with the js Service Worker it should work.
If you launch in dartium with the dart Service Worker you get an error : AbortError: The Service Worker installation failed.

If you launch in chrome with the js Service Worker you get the error : undefined is not a function on line 13
Here the register method inside ServiceWorker return normally a Future<dynamic> but instead it return a Null Object.

If you launch in chrome with the dart Service Worker your get two error :

  • undefined is not a function on line 13 the same as the javascript version
  • Operation failed by security issue

I use sdk version 1.8.5 on a windows_x64


Attachment:
testSW.zip (370.29 KB)

@sethladd
Copy link
Contributor

cc @alan-knight.
Removed Priority-Unassigned label.
Added Priority-Medium, Library-Html, Area-Library, Triaged labels.

@sethladd
Copy link
Contributor

Thanks for the report!

@alan-knight
Copy link
Contributor

ServiceWorker will not work in Dartium, at least not with Dart code, because Dartium isolates are not WebWorkers.

In dart2js the issue is that register returns a Promise, and dart2js/ the dart:html library doesn't know how to deal with Promises. That's fixable, and seems important.

For both, I think the short term workaround would be to use the Service Worker as compiled to JS, and to do the registration using JS interop.


Set owner to @alan-knight.
Removed Priority-Medium label.
Added Priority-High, Accepted labels.
Changed the title to: "Service Worker doesn't work because dart2js doesn't understand Promise".

@kasperl
Copy link

kasperl commented Mar 20, 2015

Added this to the 1.10 milestone.

@alan-knight
Copy link
Contributor

Removed this from the 1.10 milestone.
Marked this as being blocked by #21573, #23007.

@DartBot DartBot added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures library-html area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Apr 17, 2015
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed accepted labels Feb 29, 2016
@pietergreyling
Copy link

Do we have an update regarding Dart Service Worker support? It would also be useful to be able to plug in any existing Service Worker code written in JavaScript via Dart/JS interop.

@kevmoo kevmoo added the library-html-worker Issues related to Web Workers and Service Workers label Feb 24, 2018
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
@matanlurey
Copy link
Contributor

I believe this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html library-html-worker Issues related to Web Workers and Service Workers P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants