-
-
Notifications
You must be signed in to change notification settings - Fork 310
Runtime plugin lifecycle events only run once on server side #1939
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
Comments
Hmm this is interesting. Im guessing its due to module cache of webpack - it may not be invalidating when remote changes. Do you want per-invocation hoook calls, or is it getting stuck and when remote updates, host doesnt fire hooks again etc? |
@ScriptedAlchemy yeah that's what it feels like. We need per-invocation hook calls, but it is also getting stuck when remotes update, hooks don't fire again. |
Gotcha. Okay so a dirty hack you can do is clear require cache and force node to reboot webpack instance. If you look in node package you will see hot reload file. You could implement something like that but it will slow down startup time as it's not super efferent but will work. After reading the issue. This would be brilliant feature to support so we are going to look into if it's possible to do something more efficient like just call the module factory again. Not wipe everything and start again. Just make webpack forgetful |
@ScriptedAlchemy thanks for having a look, it would be great for something official to support this! I've been trying to achieve something with clearing the require cache, in the same way that hot-reload works but not having much joy yet. Something else seems to be keeping a reference to the server side module. I've also had a go at deleting the module from the host origin.moduleCache, during the before init hooks, but that doesn't seem to have an impact, even when along side the require cache clearing. And finally, I've been exploring creating another webpack plugin to try and inject a script to run before MF and next.js but that's not looking too promising at the moment either. Any pointers would be much appreciated! Many thanks |
I think I have found the cause of this, need to clean up Then, as well as clearing the required cache, I need to delete |
We need the cache in CSR, so it can not delte directly. |
Sorry @2heal1 I've been head down working on our implementation; came back here to PR it and found @ScriptedAlchemy has got a very similar implementation up in a PR #1985 🥳 |
Yeah so i have the force option im adding, but still needs to be released - if you enable that itll reset per invocation (be warned this will probs impact server perf to nuke require cache each time) |
Stale issue message |
Describe the bug
Hi,
I've been trying out the new runtime plugin for our Next.js SSR setup, but all of the server-side lifecycle events are only running once on the first page load.
The new runtime plugin is looking great, and it sounds like it will help us do everything we've been hoping for if we can get this bit working; thanks!
Reproduction
https://github.com/jonthomp/nextjs-module-federation/tree/with-runtime-plugin
Used Package Manager
npm
System Info
Validations
The text was updated successfully, but these errors were encountered: