vite icon indicating copy to clipboard operation
vite copied to clipboard

Build is failing with Unfinished hook action(s) on exit: (proxyRemoteEntry) load "virtual:mf-REMOTE_ENTRY_ID"

Open mshima opened this issue 1 year ago • 8 comments

Is there a way to debug the error?

x Build failed in 2.20s
error during build:
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(proxyRemoteEntry) load "virtual:mf-REMOTE_ENTRY_ID"

mshima avatar Oct 03 '24 21:10 mshima

With VSCode you can run scripts in debug mode and you can use the breakpoints to proceed step by step.

gioboa avatar Oct 03 '24 21:10 gioboa

Is there a way to debug the error?

x Build failed in 2.20s
error during build:
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(proxyRemoteEntry) load "virtual:mf-REMOTE_ENTRY_ID"

Could you provide a reproducible example? I have a general idea of the cause of this error, but I don’t know how to reproduce it.​ @mshima

zhangHongEn avatar Oct 04 '24 00:10 zhangHongEn

@zhangHongEn I've found the error. The exposed modules was not found. Execution vite correctly shows the error message, but vite build erroring with this error.

Happened when migrating from Webpack which does not require vue extension in exposes.

mshima avatar Oct 04 '24 12:10 mshima

@mshima Can we add a warning in the terminal for this?

gioboa avatar Oct 04 '24 15:10 gioboa

@mshima Can we add a warning in the terminal for this?

Would be nice to fail with correct error message.

mshima avatar Oct 04 '24 18:10 mshima

Can we throw the correct one?

gioboa avatar Oct 05 '24 19:10 gioboa

Image build fail in linux,but work well in windows10

BanShan-Alec avatar May 13 '25 03:05 BanShan-Alec

Image build fail in linux,but work well in windows10

https://github.com/module-federation/vite/issues/245 same issue in docker env

BanShan-Alec avatar May 13 '25 08:05 BanShan-Alec

I just ran into this and debugged the code

? {
                  find: new RegExp(`(.*${PREBUILD_TAG}.*)`),
                  replacement: function ($1: string) {
                    const pkgName = (VirtualModule.findModule(PREBUILD_TAG, $1) as VirtualModule)
                      .name;
                    return pkgName;
                  },
                }
              : {
                  find: new RegExp(`(.*${PREBUILD_TAG}.*)`),
                  replacement: '$1',
                  async customResolver(source: string, importer: string) {
                    const pkgName = (
                      VirtualModule.findModule(PREBUILD_TAG, source) as VirtualModule
                    ).name;
                    const result = await (this as any)
                      .resolve(pkgName, importer)
                      .then((item: any) => item.id);
                    if (!result.includes(_config.cacheDir)) {
                      // save pre-bunding module id
                      savePrebuild.set(pkgName, Promise.resolve(result));
                    }
                    // Fix localSharedImportMap import id
                    return await (this as any).resolve(await savePrebuild.get(pkgName), importer);
                  },
  static findModule(tag: string, str: string = ''): VirtualModule | undefined {
    if (!patternMap[tag])
      patternMap[tag] = new RegExp(`(.*${packageNameEncode(tag)}(.+?)${packageNameEncode(tag)}.*)`);
    const moduleName = (str.match(patternMap[tag]) || [])[2];
    if (moduleName)
      return cacheMap[tag][packageNameDecode(moduleName)] as VirtualModule | undefined;
    return undefined;
  }

Issue is if you return undefined; the promise resolves, but then it tries to access meta on undefined. This needs to be handled and an error thrown if its not in the maps?.

Meaning you need to add X to your package.json

Hopefully someone can make a PR for this as the issue seems to be simple. I am personally waiting to move to rolldowns MF plugin long term, so I likely won't contribute on this, past this info.

pcfreak30 avatar May 20 '25 22:05 pcfreak30

Getting same error on windows...did anyone managed to reolve this ?

amitpatil321 avatar Jun 03 '25 12:06 amitpatil321

Getting the same error on Mac. Patching the lib fixed it temporarily.

abdoIO avatar Jun 04 '25 07:06 abdoIO

@abdoIO can you share your patch please?

gioboa avatar Jun 04 '25 14:06 gioboa

@abdoIO can you share your patch please?

https://github.com/module-federation/vite/issues/132#issuecomment-2895948769 look at what i found.

pcfreak30 avatar Jun 04 '25 15:06 pcfreak30

@abdoIO can you share your patch please?

https://github.com/module-federation/vite/issues/132#issuecomment-2895948769 look at what i found.

Sorry, but can you tell us how to apply this fix and in which file ?

amitpatil321 avatar Jun 04 '25 16:06 amitpatil321

@abdoIO can you share your patch please?

#132 (comment) look at what i found.

Sorry, but can you tell us how to apply this fix and in which file ?

https://github.com/module-federation/vite/blob/1aaf099e6de71e1ae9eba4f8495e289c9d210c53/src/utils/VirtualModule.ts#L90

I forgot the details on what I did but the fix was pretty simple.

https://github.com/module-federation/vite/blob/1aaf099e6de71e1ae9eba4f8495e289c9d210c53/src/plugins/pluginProxySharedModule_preBuild.ts#L84 accesses assuming it will always be valid, causing the error

pcfreak30 avatar Jun 04 '25 17:06 pcfreak30

I resolved this build issue temporary by debuggin my vite.config file and commenting things one by one and then trying to build....i found that in my case it was 1 expose causing the error...after commenting this line...build was successful.

exposes: {
  ....,
  "./types": "./src/types/index.ts",
}

amitpatil321 avatar Jun 09 '25 08:06 amitpatil321

In my case, the error was on CI but not locally, fixed by moving the "react" plugin below the MFE@Vite in the config.

artem-tarasenko avatar Jul 17 '25 06:07 artem-tarasenko

This error only appears to happen in our Ubuntu instances, in both CI and local. MacOS and Windows build just fine.

EDIT: Import path typo caused Ubuntu build to fail. Somehow worked in MacOS and Windows.

Judd2000 avatar Jul 18 '25 18:07 Judd2000

Is there a plan to release this in a 1.8.1 version? Thank you in advance.

jonpollock avatar Sep 19 '25 03:09 jonpollock

Is there a plan to release this in a 1.8.1 version? Thank you in advance.

It is PR https://github.com/module-federation/vite/pull/336 if interested.

pcfreak30 avatar Sep 19 '25 05:09 pcfreak30

Is there a plan to release this in a 1.8.1 version? Thank you in advance.

Released 👍

gioboa avatar Sep 19 '25 06:09 gioboa

Got same error, after some debugging found that my employer's build system copying files of my package to other directory for isolated builds. And doesn't copies .css files, so this resolve never happens: https://github.com/module-federation/vite/blob/main/src/plugins/pluginModuleParseEnd.ts#L55

Is it possible, maybe, to print problematic files within the error? I started to print difference between parseStartSet and parseEndSet, got newly imported files in my PR, looked at them and found that they all importing .css files and they are not included in our build system config. But way to debug this was non-trivial and I still not understand why I got module federation error instead of some vite error that imports cannot be resolved.

UPD: oh, I remembered, I also tried to just call _resolve(1) with if (parseStartSet.size === 2300 && parseEndSet.size === 2296) { _resolve(1); } (to call it right before error) and finally got error about missing files for imports.

Rulexec avatar Sep 26 '25 11:09 Rulexec