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

Package from host app is not always available in remote app. #3193

Open
5 tasks done
adam187 opened this issue Nov 7, 2024 · 3 comments
Open
5 tasks done

Package from host app is not always available in remote app. #3193

adam187 opened this issue Nov 7, 2024 · 3 comments

Comments

@adam187
Copy link

adam187 commented Nov 7, 2024

Describe the bug

First of all, big thx for all the great work on the MF ecosystem!

I'm trying to split our app using module federation and I'm facing with weird issue that I'm having hard time figuring out.

The setup is:
Host using @modern-js@2.60.5 and @module-federation/modern-js0.7.1
Host also use enableCustomEntry but it's changed to async like specified in docs

Remote using@[email protected] and @module-federation/[email protected]
This app only expose some components to host app and also consume some components from the host app in this components.

Overall setup seams to be working but sometime I was getting some edge case race condition when component from host app was somehow empty and the export from module was only containing {Symbol(mf_module_id): 'host/Component'} without actual exports.

After some trial and error I added this plugin that somehow helped with the issue but not in 100% of cases.

import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime'

const preloadModulePlugin: () => FederationRuntimePlugin = function () {
  return {
    name: 'preload-module-plugin',
    onLoad(args) {
      args.exposeModuleFactory()

      return args
    },
  }
}

export default preloadModulePlugin

I'm still facing this issue in place of our application but now it's not reproducible manually but only via our cypress E2E tests (previously it was reproducible manually as well but not all the time and sometime component was available as it should)

I was trying to prepare reproducible repo but on simple example this issue is not reproducible.

Any ideas what could cause this kind of behaviour?

Reproduction

https://github.com/adam187/mf-example

Used Package Manager

yarn

System Info

System:
    OS: macOS 12.7.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 131.16 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 22.11.0 - ~/.local/state/fnm_multishells/2872_1730880894131/bin/node
    Yarn: 1.22.21 - ~/node_modules/.bin/yarn
    npm: 10.9.0 - ~/.local/state/fnm_multishells/2872_1730880894131/bin/npm
    pnpm: 9.8.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.31 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 130.1.71.123
    Chrome: 130.0.6723.92
    Edge: 130.0.2849.68
    Safari: 15.6.1

Validations

@adam187 adam187 changed the title Package from host app is not always available in sub app. Package from host app is not always available in remote app. Nov 7, 2024
@ScriptedAlchemy
Copy link
Member

does this error / log show only symbol in client side or server side or both?

@2heal1
Copy link
Member

2heal1 commented Nov 8, 2024

Hmmm I can not reproduce it ... Can you provide steps that can be reproduced as much as possible ?

@ScriptedAlchemy
Copy link
Member

Otherwise can you hit me on Twitter so we can zoom and i can see your actual system. This is near impossible to diagnose without being able to replicate and we have not seen it on any of our thousands of apps at bytedance

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

3 participants