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

Upstream remoteEntry.js updates with 'react-18-ssr' architecture throws errors #3167

Open
andrewstec opened this issue Sep 27, 2023 · 5 comments

Comments

@andrewstec
Copy link

andrewstec commented Sep 27, 2023

Is the React-18-ssr architecture intended to adapt to changing upstream remoteEntry.js files? I tried this architecture and when my upstream app reloaded, I had trouble refreshing the SSR application to perform a re-render and therefore the rehydration threw an error:

Error
Text content does not match server-rendered HTML.
Call Stack
 checkForUnmatchedText
  remoteEntry.js:10736:11
 didNotMatchHydratedTextInstance
  remoteEntry.js:12483:5
 prepareToHydrateHostTextInstance
  remoteEntry.js:13695:13

It looks like there will be errors when an upstream application changes unless the SSR application is restarted. I tried to remove the App from the module cache to workaround this issue when a change is detected. In a production environment, it would be necessary to avoid the "Text content does not match server-rendered HTML." The remotes would not be in the same container and there would be synchronization issues that result in this error appearing in production.

This example seems robust except for this potential issue. I have looked for a graceful runtime fix but could this be a limitation to the architecture?

@andrewstec andrewstec changed the title Upstream remoteEntry.js updates with react-18-ssr architecture Upstream remoteEntry.js updates with 'react-18-ssr' architecture throws errors Sep 27, 2023
@ScriptedAlchemy
Copy link
Member

you need to clear require cache when remote changes. likely no example of that here, but module-federation/node package has the utils

@andrewstec
Copy link
Author

you need to clear require cache when remote changes. likely no example of that here, but module-federation/node package has the utils

Thanks @ScriptedAlchemy . I have been looking at your module-federation/node repo and issues for the logic to get express require cache completely cleared and restored using the revalidate() function your utility exposes in module-federation/node.

module-federation/core#397 (comment)

I will update you there, but thank you for answering. I see all the repos you contribute to in this area. Thank you so much!

@ScriptedAlchemy
Copy link
Member

Yeah for express you need to clear the route stack, the node readme has a section on clearing express route stack cache

@ScriptedAlchemy
Copy link
Member

We are also working on fast refresh and HMR support, this should useable in production node too, so we can use webpack effecent HMR in prod servers to elegantly replace modules as they are updated instead of the nuclear option of wiping the require cache

@andrewstec
Copy link
Author

We are also working on fast refresh and HMR support, this should useable in production node too, so we can use webpack effecent HMR in prod servers to elegantly replace modules as they are updated instead of the nuclear option of wiping the require cache

That sounds amazing. Is there something on a roadmap that I can track? I will keep my eyes open!

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