Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Retrying failed to fetch dynamically imported modules #116

@blittle

Description

@blittle

I'm trying to understand how to resolve the following scenario:

  1. The user is online and loads my web app.
  2. Later, the user goes offline and navigates somewhere in the app which triggers a dynamically imported module resolved via an import map.
  3. Because I'm offline, the module loading will result in an error of Failed to fetch dynamically imported module. The app notifies the user that they are offline.
  4. Now the user reconnects and becomes online.
  5. We retry the original module fetch, which fails because the browser never retries the original request.

If I wasn't using import maps, I could force a retry by adding a query parameter to the URL I'm importing. With module maps, is there any way to retry a module import that has previously failed?

Note: in my scenario above, I could solve the problem by building a wrapper around the native import() that keeps track of whether the user is online/offline and prevent a module request from going out unless they are online. But that doesn't resolve all of the scenarios where a module resolution might fail, and the app may want to retry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions