/mf-enhanced-before-request-issue

Showcase that mf enhanced errorLoadRemote hook doesn't handles error thrown from the beforeRequest hook.

Primary LanguageJavaScript

mf-enhanced-before-request-issue

Related to the following issue: module-federation/core#2371.

The monorepo contains 3 applications:

Instructions to reproduce the issue

First install the dependencies with PNPM:

pnpm install

Then, start the solution by executing the following command at the root of the workspace:

pnpm dev

You should that the application cannot render because an error has been thrown:

Error
[ Federation Runtime ]: [ Federation Runtime ]: Error thrown from the beforeRequest hook.

Even if there's an errorLoadRemote hook configured for the host application:

export default function () {
    return {
        name: "custom-runtime-plugin",
        async beforeRequest(args) {
            console.log("*********beforeRequest", args);

            throw new Error("Error thrown from the beforeRequest hook.");

            return args;
        },
        async errorLoadRemote(args) {
            console.log("*********errorLoadRemote", args);
        }
    }
}