core icon indicating copy to clipboard operation
core copied to clipboard

RetryPlugin fallback url for scripts

Open kmilov opened this issue 1 year ago • 5 comments

Describe the bug

By implementing the RetryPlugin I am able to return a fallback url like:

import { RetryPlugin } from '@module-federation/retry-plugin';

const retryPlugin = () =>
    RetryPlugin({
        fetch: {
            fallback(_url) {       // _url => https://cdn-that-fails.com/app/
                      return 'http://localhost/app/mf-manifes.tjson'
            }
        },
    });

export default retryPlugin;

it seems that works and I can see the manifest being loaded from the fallback url, but subsequent script requests are loaded from failing CDN URL.

shouldn't the scripts also be loaded from the fallback URL ? or am I missing something ?

Reproduction

https://github.com/kmilov/rerty-plugin-issue

Used Package Manager

npm

System Info

System:
    OS: macOS 15.5
    CPU: (16) arm64 Apple M4 Max
    Memory: 842.73 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - /usr/local/box/nodejs/bin/node
    npm: 11.0.0-pre.0 - /usr/local/box/npm/bin/npm
    pnpm: 10.4.1 - ~/local/bin/pnpm
  Browsers:
    Chrome: 137.0.7151.104
    Safari: 18.5

Validations

kmilov avatar Jun 13 '25 14:06 kmilov

@kmilov How can I reproduce in the demo?

danpeen avatar Jun 17 '25 11:06 danpeen

@danpeen I just added a README to the Reproduction repo https://github.com/kmilov/rerty-plugin-issue/tree/main

kmilov avatar Jun 17 '25 11:06 kmilov

what about using the remotes array fallback pattern instead of a hook? Something like this will also be a way to achieve similar.

'mfe': ['mfe@http://localhost:8083/mf-manifest.json', 'mfe@https://cdn-that-fails.com/app/mf-manifest.json'],

zackarychapple avatar Jun 17 '25 14:06 zackarychapple

did not know about that, thx @zackarychapple.

Unfortunately does not fit my use case, as I am using registerRemote instead of registering at build time.

kmilov avatar Jun 17 '25 14:06 kmilov

Stale issue message

github-actions[bot] avatar Aug 16 '25 15:08 github-actions[bot]