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

[Bug]: HMR fails with RSPack v0.7.1 #6740

Closed
markmssd opened this issue Jun 5, 2024 · 13 comments
Closed

[Bug]: HMR fails with RSPack v0.7.1 #6740

markmssd opened this issue Jun 5, 2024 · 13 comments
Assignees
Labels
bug Something isn't working need reproduction

Comments

@markmssd
Copy link

markmssd commented Jun 5, 2024

System Info

MacOS 14.4.1

Details

With RSPack v0.7.1, HMR seems to have issues. Here is the stack trace:

app1 start: Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
app1 start: Message:  should have module graph module
app1 start: Location: crates/rspack_core/src/module_graph/mod.rs:563
app1 start: Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
app1 start: Run with RUST_BACKTRACE=full to include source snippets.
app1 start: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
app1 start:  1: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  2: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  3: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  4: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  5: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  6: _wasmer_vm_imported_memory32_atomic_notify
app1 start:     at <unknown source file>
app1 start:  7: _wasmer_vm_imported_memory32_atomic_notify
app1 start:     at <unknown source file>
app1 start:  8: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start:  9: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 10: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 11: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 12: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 13: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 14: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 15: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 16: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 17: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 18: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 19: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 20: _napi_register_module_v1
app1 start:     at <unknown source file>
app1 start: 21: __pthread_joiner_wake
app1 start:     at <unknown source file>
Screenshot 2024-06-05 at 1 43 00 PM

I have included a reproducible. It is based on https://github.com/module-federation/module-federation-examples/tree/master/advanced-api/dynamic-remotes, but with upgraded RSPack.

Note that with v0.7.0, HMR worked without problem.

Reproduce link

https://github.com/markmssd/module-federation-runtime-shared/tree/rspack-0.7.1

Reproduce Steps

git clone https://github.com/markmssd/module-federation-runtime-shared/tree/rspack-0.7.1
cd  module-federation-runtime-shared
pnpm install
pnpm start

// everything works so far.
// edit any file, e.g. `app1/src/App.js`, to trigger HMR
// it crashes 💥
@markmssd markmssd added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jun 5, 2024
@markmssd
Copy link
Author

markmssd commented Jun 5, 2024

Digging a bit more, I'm seeing #6670 and #6694 that might be related, since they're touching the module graph as reported by the error, @jerrykingxyz would you know why this could happen? 🙏🏼

@jerrykingxyz jerrykingxyz self-assigned this Jun 6, 2024
@jerrykingxyz jerrykingxyz removed the pending triage The issue/PR is currently untouched. label Jun 6, 2024
@jerrykingxyz
Copy link
Collaborator

fixed by #6730

@markmssd
Copy link
Author

markmssd commented Jun 6, 2024

Thanks for the quick fix @jerrykingxyz !

I tried with v0.7.2-canary-c66cfe5-20240606035303 and it's working perfectly in the reproducible 👌🏼

On our project, it still sometimes fails with this error:

Screenshot 2024-06-06 at 9 14 18 AM

But that might be from our setup, or because we have a large code base 🤔 I will investigate a bit more and try to reproduce it, but would you know what could cause this?

@markmssd
Copy link
Author

markmssd commented Jun 6, 2024

Ok so seems that using

      new rspack.container.ModuleFederationPlugin({
        name: 'core',
        shared,
      }),

is what makes it fail, however using

      new rspack.container.ModuleFederationPluginV1({
        name: 'core',
        shared,
      }),

works without issue! Still weird that I can't reproduce it in https://github.com/markmssd/module-federation-runtime-shared/tree/rspack-0.7.1 though, I'll keep trying, but let me know if you have an idea of what could be wrong 🙏🏼

Edit: I've also tried with @module-federation/enhanced/rspack@0.18.0 and with @module-federation/runtime directly but it's the same outcome.

E

@opsidao
Copy link

opsidao commented Jun 7, 2024

FWIW I'm seeing the same issue with:

{
  "dependencies": {
    "@module-federation/enhanced": "^0.1.18",
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  },
  "devDependencies": {
    "@rsbuild/core": "^0.7.3",
    "@rsbuild/plugin-react": "^0.7.3",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "typescript": "^5.4.2"
  }
}

on MacOS Sonoma 14.5 (23F79) (arm)

Copy link
Contributor

github-actions bot commented Jun 7, 2024

Hello @markmssd, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction will be closed if no activities in 14 days.

@ahabhgk
Copy link
Collaborator

ahabhgk commented Jun 7, 2024

About the module federation issue, we need a reproduce here, or if you really can't reproduce you can provide the config file, I will try to reproduce based on the config file once my time available

@opsidao
Copy link

opsidao commented Jun 7, 2024

@ahabhgk would something like this work?

@ahabhgk
Copy link
Collaborator

ahabhgk commented Jun 7, 2024

The panic should already been fixed, try the latest nightly version

@opsidao
Copy link

opsidao commented Jun 7, 2024

Confirmed, the panic is fixed in the nightly, thanks @ahabhgk !

@markmssd
Copy link
Author

markmssd commented Jun 8, 2024

@ahabhgk I was finally able to reproduce the issue, there you go: https://github.com/markmssd/module-federation-runtime-shared/tree/rspack-0.7.2-canary.

It's a problem only with dynamic imports. In this repro, it would be app1/src/DynamicPage.js. Editing this file will result in this error:

Screenshot 2024-06-07 at 8 20 03 PM

If you edit any other page, for example app1/src/App.js, it does not happen. I've also noticed that commenting out ModuleFederationPlugin in app1/rspack.config.js would fix it (however we wouldn't have Module Federation anymore so it's not really a solution, but could help pinpoint the issue).

Also, once the error happens, you can refresh the page and then you'll be able to edit the DynamicPage without any errors anymore. That means you'll need to stop/start the app again in order to reproduce.

Let me know if you need more info, I'd be glad to help further.

@markmssd
Copy link
Author

Hey @ahabhgk , just checking whether you had an idea why that would happen, and if you were able to see the error on the reproducible.

Also, should I re-open a new issue for it since the initial issue is technically resolved already?

@ahabhgk
Copy link
Collaborator

ahabhgk commented Jun 11, 2024

Let's move to the new issue #6773, I will take a look in the next one or two days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need reproduction
Projects
None yet
Development

No branches or pull requests

4 participants