Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error boundary doesn't work in NextJS when the remote is offline #3344

Open
5 tasks done
plamen-flutter opened this issue Dec 11, 2024 · 3 comments
Open
5 tasks done

Comments

@plamen-flutter
Copy link

Describe the bug

We used [email protected] with pages router and we relied on an error boundary to catch the error generated when a remote is offline.
For example:

Screenshot 2024-12-11 at 15 00 34

This worked fine until we updated to a newer NextJS version (14.2.3). Now the error is being ignored by the error boundary. We have also tried updating to the latest @module-federation/nextjs-mf version as of today (8.8.5), but the issue persists.

Reproduction

Configure a basic application using @module-federation/nextjs-mf with a host and a remote and start only the host application.

Used Package Manager

yarn

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 1.99 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 3.6.1 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
  Browsers:
    Chrome: 131.0.6778.109
    Edge: 131.0.2903.86
    Safari: 18.1.1

Validations

@ScriptedAlchemy
Copy link
Member

Are you using React.lazy? You can use next/dynamic with federation.

@plamen-flutter
Copy link
Author

Are you using React.lazy? You can use next/dynamic with federation.

We are using next/dynamic. Also tried it with React.lazy, but it made no difference.

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Dec 13, 2024

use errorLoadRemote hook, you can see the error logged in your browser is from the default runtime plugin for next.
also dont use next/dynamic

https://github.com/module-federation/core/blob/main/packages/nextjs-mf/src/plugins/container/runtimePlugin.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants