Implement "module" service workers
Categories
(Core :: DOM: Service Workers, enhancement, P3)
Tracking
()
People
(Reporter: bkelly, Assigned: hsingh)
References
(Blocks 5 open bugs)
Details
(4 keywords)
User Story
web-feature: js-modules-service-workers platform-scheduled:2025-12-31 user-impact-score:200
Attachments
(6 files, 1 obsolete file)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
Comment 1•8 years ago
|
||
Updated•8 years ago
|
Comment 3•6 years ago
|
||
It might be helpful to error and link to this bug when users attempt to navigator.serviceWorker.register(url, {type: 'module'}) to make it more clear that the implementation of this is not complete. This is Chrome's current behaviour.
Updated•3 years ago
|
Comment 4•3 years ago
|
||
Depends on D156103
Comment 5•3 years ago
|
||
I'll update the in progress patch, but here is the current state:
the patch largely works, however we are breaking certain constraints: Specifically,
- we need to disable top level await for service workers via a flag that is passed to spidermonkey
- we need to disable dynamic import once it lands.
Otherwise we are passing a good chunk of the tests here.
Comment 7•2 years ago
|
||
It seems like this shouldn't be too hard to do, going to take the bug although this will not be immediate and it may end up making sense to fix bug 1808685 as part of our tech debt cleanups first. (Note that the landed patch was a disabling of a prior attempt to do that, not a fix.)
(In reply to Yulia Startsev [:yulia] | Back in Oct. from comment #5)
I'll update the in progress patch, but here is the current state:
the patch largely works, however we are breaking certain constraints: Specifically,
- we need to disable top level await for service workers via a flag that is passed to spidermonkey
Here's the CompileOptions flag to set.
- we need to disable dynamic import once it lands.
Yulia already implemented the check to bail out in this case, although it's currently after we do the work to create the dynamic loader, which is weird, but the initial landing state was that way per the diff for that section.
Comment 9•1 year ago
|
||
Hey I'm interested in pushing this forward. Is it necessary to fix 1808685, or can we replicate Yulia's change on top of current HEAD and it should be mostly there?
Comment 10•1 year ago
|
||
Comment 11•1 year ago
|
||
Took a crack at implementation and was able to run it against a local app (with module serviceworkers and import statements) I've been working on!
I'm assuredly missing some implementations of equality checks and things like that, so it would be helpful to get someone who knows the surrounding code to take a look.
I'd love to pull in the related WPT tests for service worker modules, but I'm not familiar with how to do that.
Comment 12•1 year ago
|
||
Thanks for trying your hand! I think the main things that are missing are disabling top-level await and the ServiceWorkerRegistrar persistence which requires a schema version change to the file. As a heads-up, we have a few in-flight priority patch stacks right now that are likely going to bit-rot some of the plumbing in the patch over the next 1-2 weeks.
Comment 13•1 year ago
|
||
Awesome. Could we get away with sticking the new field at the end of the serialization and default to ModuleType::Classic if we hit the terminator early? (or would that constitute a version change anyway).
No worries about the bitrot. I won't rest until every -Info -Data -Registrar -Parent and -Child has a WorkerType aType in its constructor.
Comment 14•1 year ago
|
||
thanks for taking this over!
Comment 15•1 year ago
|
||
(In reply to John Renner from comment #13)
Awesome. Could we get away with sticking the new field at the end of the serialization and default to
ModuleType::Classicif we hit the terminator early? (or would that constitute a version change anyway).
That would constitute a version change anyway, because the logic that makes sure the registration terminator is where we expect it would discard the registrations anyways on (unsupported[1]) downgrade.
A nice part of bumping the rev is that we can also then potentially write "module" or "classic" adjacent to the cache UUID that makes the file format a little bit more human readable than just stashing it as a new last line.
1: So although there is a defensive build id ratchet on profiles now that yells at users if they try and downgrade, we do try and "handle" downgrades so that people doing bisection or having to roll-back at least won't get into super-weird states.
Comment 16•1 year ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Comment 17•1 year ago
|
||
Hey there -- I just wanted to voice some support for this issue. I've been working on building a cross-platform service worker for a library called Automerge which works across the Blink family of browsers, Safari, and Firefox. Unfortunately, Firefox (in service workers) is the odd platform out right now and my users are complaining. I'd really really like not to open the can of worms that it would entail to develop and test yet another version of the library that works cross platform that is only for service workers based on importScripts, particularly since there seems to be some energy around landing this feature in Firefox.
I'm happy to test builds, and provide validation (technical or emotional) if it helps get this patch landed.
Comment 18•1 year ago
|
||
WebGPU CTS uses module workers for coverage of service workers. Also, most service worker demos I'm aware of for WebGPU use module scripts. This makes deployment of service workers for WebGPU applications in Firefox require additional work, and hurts our story for Firefox as a developer's primary developer browser.
Comment 19•1 year ago
|
||
The WebGPU project and our internal ML team has blockers that are (now) depending upon this. Additionally, we have people at huggingface.io who are also wanting to have this available--a vast majority of the service worker dependencies they have are with module workers. Can we get this issue resuscitated and its priority elevated?
Comment 20•1 year ago
|
||
Apologies for not coming back to this (despite an admittedly my bold declaration above). I continue to not have time amongst the many responsiblities of life. The change shouldn't be too bad for someone with knowledge of the code since most of the underlying support in the runtime is there, it's mostly just threading the flag.
Comment 21•1 year ago
|
||
Just a note that over here at Ink & Switch we're building local-first projects that rely heavily on Service Workers and don't support Firefox because of this missing feature. We have had a few sad folks as a result and I'd love to have Firefox support.
Updated•1 year ago
|
Comment 22•1 year ago
|
||
Hi all! I'd also like to voice support for this issue. I'm the lead maintainer of Transformers.js, a JavaScript library for running ML models in the browser, and many of our users (and those testing our demos) have mentioned that they often run into browser issues when using Firefox. One of which, is this one: module support in service workers. So, it would be great to have this working!
We've released a bunch of demos that can help with testing; hopefully they will be useful:
- Online demos
- Source code
- Posts on reddit (really great user feedback, including comments)
Comment 23•9 months ago
|
||
(In reply to Joshua Lochner from comment #22)
We've released a bunch of demos that can help with testing; hopefully they will be useful:
- Online demos
- Source code
- Posts on reddit (really great user feedback, including comments)
Hi Josh, can you point to a specific demo that requires module support in service workers?
Updated•9 months ago
|
Comment 24•9 months ago
|
||
(In reply to Peter van Hardenberg from comment #21)
Just a note that over here at Ink & Switch we're building local-first projects that rely heavily on Service Workers and don't support Firefox because of this missing feature. We have had a few sad folks as a result and I'd love to have Firefox support.
Peter, can you share some examples?
Comment 25•9 months ago
•
|
||
Sure thing!
One easy example is this project here which uses our Automerge library
in a service-worker: https://github.com/pvh/trail-runner
There's a copy of it uploaded here: https://am.pvh.ca/@pvh.ca/www/
(If I remember correctly the service worker simply fails to load on FF
without a lot of helpful error messages but that might have been a
different bug.)
It should report an error linking to the bug in Firefox but the code
of the service-worker can illustrate the use:
https://github.com/pvh/trail-runner/blob/main/src/service-worker.js
You can see that I am importing modules there. This code works in all
other browsers I'm aware of, including Chrome, Edge, and Safari.
Our as-yet-unpublished Patchwork project has a horrifying workaround
with a custom one-off build & bundle for the service worker due to the
fact that Vite reasonably assumes every part of Firefox has support for
the same language features. That does work in Firefox but makes me very
very sad and was expensive to build and is annoying to maintain.
Let me know if I can provide any further examples. I've spent an extraordinary
amount of time working on build systems and fighting package managers
because of this bug and I would love to help make sure nobody else does.
Updated•9 months ago
|
Updated•8 months ago
|
Comment 26•8 months ago
|
||
Thanks for forwarding the needinfo. Will bring to team backlog discussion.
Updated•8 months ago
|
Updated•7 months ago
|
Comment 27•7 months ago
|
||
Redirect a needinfo that is pending on an inactive user to the triage owner.
:edenchuang, since the bug has recent activity, could you have a look please?
For more information, please visit BugBot documentation.
| Assignee | ||
Updated•6 months ago
|
Comment 28•6 months ago
|
||
Harveer -- thanks for picking this one up. Getting this fixed will make a big difference to supporting our work (and indeed a lot of modern JS) in Firefox. Let me know if there's anything I can test or give input on. Also -- I see that there's a needinfo flag on the bug. I believe my response above should have cleared that so I'll mark it thus below.
| Assignee | ||
Comment 29•6 months ago
|
||
| Assignee | ||
Comment 30•6 months ago
|
||
| Assignee | ||
Comment 31•6 months ago
|
||
| Assignee | ||
Comment 32•6 months ago
|
||
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
| Assignee | ||
Comment 33•4 months ago
|
||
Comment 34•4 months ago
|
||
Comment on attachment 9521470 [details]
Bug 1360870: Service worker module registration should be rejected in case of any evaluation errors.r=edenchuang,asuth
Revision D269457 was moved to bug 1995558. Setting attachment 9521470 [details] to obsolete.
Comment 35•4 months ago
|
||
Comment 37•4 months ago
|
||
Comment 38•4 months ago
|
||
Backed out for causing failures at browser_dbg-browser-toolbox-workers.js.
Backout link: https://hg-edge.mozilla.org/integration/autoland/rev/254ce923c1e5e7c8c431340e57520f419c104d2d
Failure log: https://treeherder.mozilla.org/logviewer?job_id=533577930&repo=autoland&task=RKebz0mVQ7--f2vH4XEIUw.0&lineNumber=5140
Comment 40•4 months ago
|
||
Comment 42•4 months ago
|
||
Comment 43•4 months ago
|
||
Comment 45•4 months ago
|
||
Comment 47•4 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/d363f27ded29
https://hg.mozilla.org/mozilla-central/rev/e61feb83a39c
https://hg.mozilla.org/mozilla-central/rev/36f6edbe47a4
https://hg.mozilla.org/mozilla-central/rev/776f65638b1f
https://hg.mozilla.org/mozilla-central/rev/ac46df43805a
Comment 48•4 months ago
|
||
Comment 49•4 months ago
|
||
Comment 51•3 months ago
|
||
Comment 53•3 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/6695a4a7a649
https://hg.mozilla.org/mozilla-central/rev/5e854a4d5fcc
https://hg.mozilla.org/mozilla-central/rev/0dc4ed5913a7
https://hg.mozilla.org/mozilla-central/rev/61e88493ad15
https://hg.mozilla.org/mozilla-central/rev/be5b6a995776
Comment 57•3 months ago
|
||
Please make sure to request a release note for this.
| Assignee | ||
Updated•3 months ago
|
Comment 58•3 months ago
|
||
FF147 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/42249
Updated•3 months ago
|
Comment 59•3 months ago
|
||
(In reply to Tom S. (please needinfo tschuster) from comment #57)
Please make sure to request a release note for this.
| Assignee | ||
Comment 60•2 months ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: Module service workers has been long supported by other major browser vendors. This has been a critical feature from a web-compat point of view as well.
[Affects Firefox for Android]: Yes
[Suggested wording]: Module service workers are now supported, aligning Firefox with other major browsers and improving compatibility for modern web apps.
[Links (documentation, blog post, etc)]: https://www.w3.org/TR/service-workers/
Description
•