From e28c7294808c9e2a0d05b2e37fc13d575c94a61b Mon Sep 17 00:00:00 2001 From: Kuitos Date: Wed, 6 Mar 2024 11:20:06 +0800 Subject: [PATCH] fix(qiankun): should remove internal cache of loadMicroApp while loading failed (#2922) --- .changeset/poor-squids-hide.md | 5 +++++ packages/qiankun/src/apis/loadMicroApp.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/poor-squids-hide.md diff --git a/.changeset/poor-squids-hide.md b/.changeset/poor-squids-hide.md new file mode 100644 index 000000000..26c73dbcc --- /dev/null +++ b/.changeset/poor-squids-hide.md @@ -0,0 +1,5 @@ +--- +"qiankun": patch +--- + +fix(qiankun): should remove internal cache of loadMicroApp while loading failed diff --git a/packages/qiankun/src/apis/loadMicroApp.ts b/packages/qiankun/src/apis/loadMicroApp.ts index 26b075258..bb8b61fb2 100644 --- a/packages/qiankun/src/apis/loadMicroApp.ts +++ b/packages/qiankun/src/apis/loadMicroApp.ts @@ -71,12 +71,21 @@ export function loadMicroApp( const parcelConfigObjectGetterPromise = loadApp(app, userConfiguration, lifeCycles); + let parcelConfigObjectGetter: ParcelConfigObjectGetter | undefined; + if (containerXPath) { const appContainerXPathKey = getContainerXPathKey(containerXPath); appConfigPromiseGetterMap.set(appContainerXPathKey, parcelConfigObjectGetterPromise); + try { + parcelConfigObjectGetter = await parcelConfigObjectGetterPromise; + } catch (e) { + appConfigPromiseGetterMap.delete(appContainerXPathKey); + throw e; + } } - return (await parcelConfigObjectGetterPromise)(container); + parcelConfigObjectGetter = parcelConfigObjectGetter || (await parcelConfigObjectGetterPromise); + return parcelConfigObjectGetter(container); }; if (!started) {