Skip to content

Commit 9685726

Browse files
Fix data prefetch timing issue - prevent afterResolve from interfering with initContainer prefetch
Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent 2cdb103 commit 9685726

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/data-prefetch/src/plugin.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export const prefetchPlugin = (): ModuleFederationRuntimePlugin => ({
104104
return options;
105105
}
106106

107+
// Check if prefetch is already initiated by initContainer
107108
const inited = loadingArray.some((info) => info.id === id);
108-
if (!inited) {
109+
if (inited) {
110+
// Prefetch already set up by initContainer, don't interfere
109111
return options;
110112
}
111113

@@ -125,11 +127,7 @@ export const prefetchPlugin = (): ModuleFederationRuntimePlugin => ({
125127
prefetchUrl = getResourceUrl(snapshot, snapshot.prefetchEntry as string);
126128
}
127129

128-
const index = loadingArray.findIndex((loading) => loading.id === id);
129-
// clear cache
130-
if (index !== -1) {
131-
loadingArray.splice(index, 1);
132-
}
130+
// Only set up prefetch if not already done by initContainer
133131
const promise = instance.loadEntry(prefetchUrl).then(async () => {
134132
const projectExports = instance!.getProjectExports();
135133
if (projectExports instanceof Promise) {

0 commit comments

Comments
 (0)