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

Host MFE is showing others duplicated MFEs in Client Side #2925

Open
5 tasks done
MaykonMorais opened this issue Sep 5, 2024 · 6 comments
Open
5 tasks done

Host MFE is showing others duplicated MFEs in Client Side #2925

MaykonMorais opened this issue Sep 5, 2024 · 6 comments

Comments

@MaykonMorais
Copy link

Describe the bug

In our production project, we are experiencing some very strange errors related to the extra loading of MFEs by the MFE Host. To provide context, we basically have our MFE Composer that communicates with MFE Mid, which in turn communicates with the other MFEs (header, content, footer). We have noticed that at certain moments the MFE Content and MFE Footer are appearing duplicated, and this behavior occurs on the client side but the project configured to use server side.

repro.video.mov

We have another project that follows the same architecture and this errors also appears and some MFEs sometimes they are rendered client side, sometimes server side.

Repos:

Reproduction

https://composer-psi.vercel.app

Used Package Manager

yarn

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 173.57 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  Browsers:
    Chrome: 128.0.6613.119
    Edge: 128.0.2739.63
    Safari: 17.6

Validations

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Sep 5, 2024

It means multiple version of react are loading. Ensure pages have a get initial props and see if that makes it any better. Ensure that all remotes use import from only and not loadRemote.

Try not using ISR or any other data loading, just put get initial props on every single page in every application and see what happens then.

I'd also suggest using modernjs which is designed for these use cases. Next is barely functional.

@MaykonMorais
Copy link
Author

Hi @ScriptedAlchemy , thanks for the quick response!

How can I avoid multiples version of react? Using shared property? Could you show me an example?

@ScriptedAlchemy
Copy link
Member

Try copying one of my examples and making minimal changes to it. Or ass getInitialProps to all your pages everywhere. Since some do not have that

@MaykonMorais
Copy link
Author

Hi @ScriptedAlchemy
We notice that some MFEs are returning this error message on the server side:

content/content offline TypeError: n.init is not a function at e7.get (remoteEntry.js:16:577) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async tx.loadRemote (remoteEntry.js:44:1547)

When this error happen the MFE is only rendered on the client side. Have you experience this error before? What could be causing this?

@ScriptedAlchemy
Copy link
Member

Yeah if it's a non ssr remote then you need to prevent hydration errors

@MaykonMorais
Copy link
Author

Got it! We solved the previous error and it was related to how we loaded emotion library. Now we see another error in our logs

footer/Footer Script execution error: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.

Is there something related about ESM Modules in Next.js? How can we solve this?

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