-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
When using the webpack plugin, if the beforeRequest hook throw an error, the errorLoadRemote hook is never called #2371
Comments
@patricklafrance beforeRequest is not necessarily errorLoadRemote - its what generates the args for loadRemote. errorLoadRemote can also return a function thats another component or module. So if you tried to do that for beforeRequest it would blow up too. Whats your use case of beforeRequest? |
I see. Isn't it part of the workflow of loading a remote though, even if it's happening "before" ? I guess what you are saying makes sense if you expect Anyway, if it's not Currently, my use case for this would be to verify if a remote is available before proceeding with Honestly, the best place to implements a timeout mechanish would be when fetching the manifest file, but I cannot currently use manifest files for my remote entry points because of #2362. |
https://github.com/module-federation/core/pull/2373/files errorLoadRemote hook now has args.lifecycle. if lifecycle is beforeRequest, you must return args for beforeRequest from hook this hook now fires for each hook so you need to be careful and ensure that you return the right things for each lifecycle that it catches |
Thank you @ScriptedAlchemy 🙏 Is there a release including this fix? |
yes already released |
Awesome i’ll give it a try, thank you 🙏 |
@ScriptedAlchemy, when you mentionned that it's released, are you saying that it's released with Whenever I throw an error in And the
I tested with the following runtime plugin: export default function () {
return {
name: "custom-plugin",
async beforeRequest(args) {
throw new Error("beforeRequest custom error");
return args;
},
async errorLoadRemote(args) {
console.log("*********errorLoadRemote", args, args.lifecycle);
return args;
}
}
} I would have expected that |
Hmm, weird, my POC is available here if you want to take a look: https://github.com/patricklafrance/mf-enhanced-poc/tree/before_request_error. Make sure to use the |
Okay when checking your installed source, i dont see my patch so im guessing the source code is not released for some reason |
Indeed it does work with |
@ScriptedAlchemy while the error is handled by the I am testing this behavior by commenting my |
Maybe consider sending a pull request and you can adjust the mechanics as you would like them to be. |
Since it's working as expected with the |
yeah go for it. I would suggest sending a PR our way, it may be easir to send over code and we can adjust is as needed vs back and forth over this lol. |
Will close for now and open another issue if needed. Yeah sounds good, I was suggesting also integrating the error handling to |
Describe the bug
When using the webpack plugin, if the
beforeRequest
hook throw an error, theerrorLoadRemote
hook is never called.With the following runtime plugin:
Configured in the host application
wepack.config.js
file:The
Error
thrown from thebeforeRequest
hook is never handled by theerrorLoadRemote
hook and it crashes the application:Reproduction
https://github.com/patricklafrance/mf-enhanced-before-request-issue
Used Package Manager
pnpm
System Info
Validations
The text was updated successfully, but these errors were encountered: