Skip to content

[web] Deprecate and remove flutter_service_worker.js #156910

Closed

Description

@ditman

Document Link

https://flutter.dev/go/web-cleanup-service-worker

What problem are you solving?

The current default service worker implementation is one of (several) approaches that can be used by Flutter web, however it's not a good fit for all use-cases.

This confuses users when it doesn't behave as they expect.

Having a default service worker implementation sends the message that it is necessary or recommended by Flutter web to function correctly, but that is not the case.

This design doc discusses how the current implementation of flutter_service_worker.js is going to be phased out (TL;DR: with a cleanup service worker for those currently using the default one), and how the flutter tools and flutter.js will eventually stop generating (or loading) a default service worker, allowing web app developers to do what's best for their specific apps.

Activity

  1. added
    📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")
    on Oct 15, 2024
  2. added
    in triagePresently being triaged by the triage team
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 16, 2024
  3. slavap commented on Oct 17, 2024

    @slavap

    @ditman

    and flutter.js will eventually stop generating (or loading) a default service worker, allowing web app developers to do what's best for their specific apps.

    the best for any web app is to have PWA "just working". If someone for some reason wants "custom PWA with different approach", let them do it, but for others 90% of "lazy" developers - the default implementation of "one of (several) approaches" is absolutely fine, just make it "dumb" and reliable as AK-47.

    As you mentioned in the doc: "Most of the web frameworks that provide a way to serve a service worker, also offer a way to clean it up, like Angular or Vite."

    Now ask yourself - why do these frameworks provide PWA functionality, but you are proposing the opposite ??? I.e. we cannot provide reliable default PWA support, so let's just eliminate it completely, and pray that the community somehow solves it instead of us.

  4. uldall commented on Oct 17, 2024

    @uldall
  5. slavap commented on Oct 18, 2024

    @slavap

    @uldall if that is correct and PWA could work without service worker - then that has to be clearly explained in the document.

  6. ditman commented on Oct 18, 2024

    @ditman
    MemberAuthor

    @slavap thanks for your message, feedback is always appreciated! (you should also be able to comment on the google doc itself if you want to!)

    To me, the biggest problem that the current default service worker has is that people think that it is mandatory, when in reality, it isn't.

    For most of Flutter web developers, the standard browser cache will work as expected, and they'll have a more familiar development and deployment experience: "deploy-full page reload-new app". (The rest 1% is providing their own service worker implementation anyway to achieve whatever extra goals they have.)

    I'm not opposed to generating service workers with Flutter web, but I think we should:

    • have a very clear idea of what the service worker is supposed to do: What happens when it goes offline? How does it react to updates? How does it cache assets? etc... I don't think we have any of this right now.
    • make it an opt-in feature (maybe make users manually register the flutter_service_worker.js, instead of doing it automatically?)
    • (Ideally) be able to use battle-tested technology that already exists (like Workbox or any other), and for that...
    • (Ideally) have the flutter tooling play nicer with other build systems

    I don't know how to get to that future yet! Maybe it can be done as a package:build, or using the upcoming Native assets feature, but I think it's better to cleanup and then try again.

    In the meantime, users who really want a service worker can build their own, without worrying that the Flutter build is going to step on their toes.


    PS: There's cool reads about "PWA", service workers and related stuff here:


    PPS: We can update the document to make any of it clearer, feel free to leave inline comments there!

  7. slavap commented on Oct 18, 2024

    @slavap

    @ditman

    (Ideally) be able to use battle-tested technology that already exists (like Workbox or any other), and for that...

    This sounds like a totally right idea to me, integrating with "battle-tested technology" and not reinventing the wheel is always great.

  8. jezell commented on Oct 18, 2024

    @jezell
    Contributor

    Love this change!

  9. lukepighetti commented on Oct 18, 2024

    @lukepighetti
    Contributor

    I do think it's reasonable for users to expect Flutter to provide a sane default PWA experience (like every other popular web framework).

    But IIRC that is blocked right now by issues like hotfixes not working as expected.

    So any short term feature losses that resolve the big issues deploying flutter web are welcome... as long as the vision for a sane default PWA experience is retained.

  10. yjbanov commented on Oct 18, 2024

    @yjbanov
    Contributor

    @ditman Can you please clarify in the doc what the plan is for the manifest.json file?

  11. rayliverified commented on Oct 19, 2024

    @rayliverified

    Does this remove cache busting? I have a concern that this will make updating Flutter Web apps successfully even harder.
    One issue that's popped up with Flutter Wasm builds is that something gets cached by the browser and stuck so newer builds often fail. New builds try to reference some symbols that are different from old builds.

    Edit: We may have variables that crash in Wasm due to unsupported typing or casting, so it could be unrelated.

    Refreshing the page does not fix. Clearing cache doesn't fix either. The only fix is "Clear application data" in dev tools.
    image

    How does this impact the updating web apps workflow?

    One thing I can see it helping is it would let me run my own service worker to clear the application data when I detect a newer version of my app from the server. But that wouldn't be out of the box behavior. So what would the default behavior and strategy be?

    Ideally, Flutter Web developers can publish a new version, the new version runs and works.
    That's not what is happening now. Would that be a goal of this change?

  12. ditman commented on Oct 21, 2024

    @ditman
    MemberAuthor

    So what would the default behavior and strategy be?

    @rayliverified The current implementation attempts to aggressively cache and pre-fetch the assets of your app; that will stop happening. The new default behavior will be "remove the default service worker, if it's installed.", so we can help "clean up" web apps that don't care about the service worker and just take "the default". Later, we will stop emitting a service worker completely so you can install your own.

    How does this impact the updating web apps workflow? [...]
    Ideally, Flutter Web developers can publish a new version, the new version runs and works. That's not what is happening now. Would that be a goal of this change?

    Yes, this change should move your app to using the default browser cache (that you can control via your CDN configuration), rather than having our own implementation on top of that. This should make your update-after-deployment experience much more straightforward, and was specifically one of the things that motivated this change!

  13. 56 remaining items

  14. self-assigned this
    on Oct 19, 2026
  15. added a commit that references this issue on Oct 31, 2026
  16. github-actions commented on Nov 12, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")P2Important issues not at the top of the work listdesign docTracks a design discussion documentplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions