Skip to content

Unable to retry loadRemote after failed attempt #3685

Open
@nameofname

Description

@nameofname

Describe the bug

We have been experiencing temporary outages which only occur on prod after starting a new container, or MFE revalidation where loadRemote is unable to fetch a remote MFE, even though the remote is published and no changes since the last deploy. The root cause of the loadRemote failures is a separate topic - this issue deals with the fact that our retry logic is currently unable to mitigate the issue - instead once loadRemote fails, it will continue to fail no matter how many times you call it.

I have created a sample repository to demo the bug here :
https://github.com/nameofname/next-module-federation/tree/master/fix-chunk-retries

IMPORTANT DISCLAIMER: Our setup uses nextjs-mf plugin and we rely on SSR for our MFEs. We're aware that it's deprecated. This is particularly relevant to this bug because the server side MFE imports (loadRemote) will fail until the node process is restarted.

After investigating, I found that the same promise is returned from loadRemote, and after diving into the code identified the handle function in @module-federation/node's runtimePlugin. I am opening a PR to address, however I'm not sure the full implications of the change, and want to discuss if it's appropriate or a different solution would work.

*Note - I also tried out using the retry plugin available from the core package and had the same issue.

Reproduction

https://github.com/nameofname/next-module-federation/tree/master/fix-chunk-retries

Used Package Manager

npm

System Info

System:
    OS: macOS 15.3.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 263.16 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.local/share/mise/installs/node/20/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - ~/.local/share/mise/installs/node/20/bin/npm
    pnpm: 10.8.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 135.0.7049.43
    Safari: 18.3.1

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions