Skip to content

[Bug]: Starting build from file cache breaks MFP runtime #9150

@AndreyGladkov

Description

@AndreyGladkov

System Info

System:
OS: macOS 15.1
CPU: (8) arm64 Apple M1
Memory: 123.52 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.11.0 - /usr/local/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.3.0 - /opt/homebrew/bin/npm
Browsers:
Chrome: 132.0.6834.160
Safari: 18.1
npmPackages:
@rspack/cli: 1.2.2 => 1.2.2
@rspack/core: 1.2.2 => 1.2.2
@rspack/plugin-react-refresh: ^1.0.1 => 1.0.1

Details

If i enable cache:

experiments: {
        cache: {
            type: "persistent",
            buildDependencies: [
                __filename,
                path.join(__dirname, "./package.json"),
            ],
        },
    }

first run is ok(without cache):
Image
if second run from cache:
Image

index.cjs.js:1494 Uncaught Error: Invalid loadShareSync function call from runtime #RUNTIME-006
args: {"hostName":"app","sharedPkgName":"react"}
https://module-federation.io/guide/troubleshooting/runtime/RUNTIME-006
    at D.loadShareSync (index.cjs.js:1494:19)
    at F.loadShareSync (index.cjs.js:1938:35)
    at f (index.cjs.js:236:35)
    at n.m.<computed> (index.cjs.js:252:29)
    at __webpack_require__ (main.js:6:1508)
    at 787 (react-dom-client.production.js:16:11)
    at __webpack_require__ (main.js:6:1508)
    at 745 (client.js:35:20)
    at __webpack_require__ (main.js:6:1508)
    at 914 (main.js:5:185971)

This happens when I load bootstrap synchronously. But in this example, dependencies are loaded before the runtime and main chunks. And this works correctly when running without cache or with cache and rspack.container.ModuleFederationPluginV1 version.

Reproduce link

https://github.com/AndreyGladkov/rspack-mfp-bug

Reproduce Steps

  1. run yarn && yarn dev
  2. run server yarn start
  3. cancel yarn dev
  4. re-run yarn dev running from cache
  5. see error in console

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions