Skip to content

Commit 0d74c69

Browse files
YanPesyannik.peschkeScriptedAlchemy
authored
docs: add eager consumption error to error-catalog.mdx (#2991)
Co-authored-by: yannik.peschke <[email protected]> Co-authored-by: Zack Jackson <[email protected]>
1 parent cfa4778 commit 0d74c69

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

apps/website-new/docs/en/guide/basic/error-catalog.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,33 @@ In addition, the option `eager` encapsulates all shared-dependencies into a dedi
107107
}
108108
```
109109

110+
## Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')
111+
112+
#### Error Message
113+
:::danger Browser Error Message
114+
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')
115+
at __webpack_require__ (builder-runtime.js:32:21)
116+
...
117+
:::
118+
119+
:::danger Browser Error Message (Specific to Rspack)
120+
Undefined factory webpack/container/remote/`remote-name`/`name-of-exposed-file`
121+
:::
122+
123+
#### Solution 1
124+
125+
**Example scenario**: You have an npm package with `eager` remote imports (such as `import Button from 'myRemote/button'`) and share this npm package with `eager: true`.
126+
**Example scenario**: You're sharing a mix of packages, some with `eager: true` and others with `eager: false`, and the `eager: true` packages import the `eager: false` shared packages.
127+
128+
This error occurs when a remote (often a library-like shared module) contains unwanted circular dependencies between the `shared dependencies` of the remote and other consumers or the host application. If the environment is using the Module Federation config `shared: { "package-name": { eager: true } }`, the Rspack/Webpack builder runtime will break with this error.
129+
130+
To resolve this, remove the `eager: true` option from the shared configuration of all connected remotes and the host application. This will prevent the shared dependencies from being eagerly loaded and will allow the remote to be loaded correctly.
131+
132+
Since eager consumption wraps all dependencies inside the entry file of the remote, Rspack/Webpack cannot detect the specific handlers for each dependency, resulting in `undefined`.
133+
134+
#### Solution 2
135+
136+
You are missing an "async boundary" in your application. Ensure that you have a dynamic import at the top of the application.
137+
For example, if your entry point is `index.js`, copy the contents of `index.js` into a new file called `bootstrap.js`. Then, in `index.js`, replace the code with `import('./bootstrap.js')`.
138+
139+
Alternatively, you can try the hoisted runtime experiment, which removes the need for an async boundary in user code. Learn more here: [Hoisted Runtime Experiment](https://module-federation.io/configure/experiments.html#federationruntime).

0 commit comments

Comments
 (0)