-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
[runtime] Manifest fetch/logger error can throw unhandleable errors #3452
Comments
let me check |
I believe we have just hit this as well. Our Nx monorepo loads remotes at startup via init(), but if any remote is misconfigured / unavailable then we hit getManifest(), which throws, and there doesn't seem to be a way to catch the error so our whole app crashes. |
i think we should let the |
Yes, that makes total sense if that is the path y'all want to take. I just didn't want to be presumptive in the original issue. Just having some way to handle errors thrown here would be great. |
Hi @hrmcdonald and @DGAISmith, I'm pleased to inform you that we've merged the PR addressing this issue. We've also published a comprehensive guide on handling remote rendering errors, which you can find here: We're planning to release an official version today that includes these improvements. The blog post details various strategies for handling remote rendering failure scenarios, which should help address the challenges you've encountered. Once the official release is out, you'll be able to implement these error handling strategies in your application. I encourage you to try them out and let us know how they work for you. Your feedback and suggestions are always valuable to us as we continue to improve Module Federation. Please don't hesitate to share your thoughts or reach out if you need any assistance. Best regards. |
Awesome news, the new blog post is great to see as well! We'll take a look when this update is published. Thanks again for looking into and resolving this one so quickly 🎉 |
Describe the bug
Issue
When the MF runtime attempts to fetch any remote registered with an
mf-manifest.json
, if it fails, an exception is thrown. Today, there is no hook for handling this. A hook exists to provide the fetch itself,.catch
ing that fetch does not resolve the issue here at all since other internal logic still "logs" the error leading to the exception being thrown regardless.Depending upon what triggered the runtime to attempt to attempt the
fetch
, it might even not be something we can catch at all. In this recreation project, I am triggering the manifest fetch manually with apreloadRemote
call. However, in our more complicated internal project (that I unfortunately cannot share here) even just shared dependency loading can lead to remote manifests getting fetched and throwing an error we cannot catch and handle. This happens in the snapshot plugin even if nothing is done with those remotes yet. This leads to the MF runtime throwing exceptions beyond our control that crash portions of our app like routing which can affect routes unrelated to the unreachable remote when any remote is unavailable at all for some reason.Cause
Any call to
SnapshotHandler.getManifest()
will cause an unhandled exception to get thrown that we potentially have no way to handle. This can be triggered bypreloadRemote
, but also by the MF runtime itself when, for example,ShareHandler.initializeSharing()
is called. That can triggerinitRemoteModule()
and eventuallygetManifest()
.While the
fetch
withingetManifest()
is itself handled with atry/catch
, it calls anerror(msg)
logging method that then rethrows an error with the logged message. I think this is really the root of the issue here tbh.Why is this a problem? Well because often times routing can trigger dependencies to be imported. The
error
thrown here disrupts that process and causes at least@tanstack/react-router
to fail on any route change even those not obviously related to the problematic remote in any way.Links to referenced methods:
Potential Solution
We need a way to handle any errors thrown by the
getManifest
fetch before it callserror(msg)
or really just exceptions thrown byerror(msg)
function in general. Anything that could log an error through that error method might result in this issue to be honest. (Does this need tothrow
the message instead of just log it as an error?)Throwing errors are fine, as long as we have a path to hook into handling them. An
errorLoadManifest
hook might fit in line witherrorLoadRemote
? Alternatively just ahandleError
hook for dealing with errors that get logged viaerror(msg)
instead of having that rethrow them no matter what.Potential Alternatives
errorLoadRemote
does not help here. This gets thrown separately from that hook regardless. I included the common example implementation for handling issues with that plugin hook to showcase it not helping here.shareStrategy
fixes this. It fixes a similar issue, but will not help handle this kind of exception getting thrown at all.There are a few other past closed issues I read through on this that were either only tangentially related or never really uncovered the heart of this particular issue. If I did miss one that calls out a way to handle this kind of edge-case though please let me know and I'll review to confirm what fix/workaround/implementation adjustment works.
Reproduction
https://github.com/hrmcdonald/mf-runtime-fetch-manifest-issue
Used Package Manager
npm
System Info
Validations
The text was updated successfully, but these errors were encountered: