mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(core): cleanup loading promise when no dependencies are defined (#53031)
This commit cleans up the `loadingPromise` when no `dependenciesFn` is defined, as it's already cleaned up after the resolution of `Promise.allSettled`. This occurs with `prefetch on` triggers, such as when `triggerResourceLoading` is called from `ɵɵdeferPrefetchOnImmediate`, where there are no dependencies to load. The `loadingPromise` should still be cleaned up because it typically involves the `ZoneAwarePromise`, which isn't properly garbage collected when referenced elsewhere (in this case, it would be referenced from the `tView` data). PR Close #53031
This commit is contained in:
@@ -655,10 +655,11 @@ export function triggerResourceLoading(tDetails: TDeferBlockDetails, lView: LVie
|
||||
}
|
||||
|
||||
// The `dependenciesFn` might be `null` when all dependencies within
|
||||
// a given defer block were eagerly references elsewhere in a file,
|
||||
// a given defer block were eagerly referenced elsewhere in a file,
|
||||
// thus no dynamic `import()`s were produced.
|
||||
if (!dependenciesFn) {
|
||||
tDetails.loadingPromise = Promise.resolve().then(() => {
|
||||
tDetails.loadingPromise = null;
|
||||
tDetails.loadingState = DeferDependenciesLoadingState.COMPLETE;
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user