Skip to content

[nextjs] v8.2.4 caches remoteEntry.js leading to stale chunks. remoteEntry is missing the ?t={date.now()} timestamp. #2208

@digitalhank

Description

@digitalhank

Describe the bug

Our federation architecture stitches together several nextjs applications. after upgrading to the latest module federation version, from 6.7.1 -> 8.2.4, we've started experiencing intermittent issues on production. What i've seen is that remoteEntry gets cached, and when the host tries to fetch the remote's chunks it fails. This is due to the chunk ids being defined in remoteEntry.

Hard refreshing the browser tab (which clears cache of all static assets on that page) resolves the issue until the remote rolls out a new version.

Below are examples of the request url from host to tenant. the latest version is missing the timestamp.
8.2.4 - https://{domain}/_next/static/chunks/remoteEntry.js
7.0.8 - https://{domain}/_next/static/chunks/remoteEntry.js?1710943728634
6.7.1 - https://{domain}/_next/static/chunks/remoteEntry.js?t=1710943381827

Thanks for the help.

FYI
The reproduction is a clone of https://github.com/module-federation/module-federation-examples/tree/master/nextjs-v13. You can see the issue there, but the local dev environment seems to carry additional issues, i'm seeing hydration errors at least.

Reproduction

https://github.com/digitalhank/remoteEntry-broken-example

Used Package Manager

npm

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M1
    Memory: 84.44 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.3.1 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 122.0.6261.129
    Safari: 17.3.1

Validations

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions