Skip to content

Commit db1a8eb

Browse files
arturovtAndrewKushnir
authored andcommitted
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
1 parent 6a13fd5 commit db1a8eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/core/src/defer/instructions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,10 +655,11 @@ export function triggerResourceLoading(tDetails: TDeferBlockDetails, lView: LVie
655655
}
656656

657657
// The `dependenciesFn` might be `null` when all dependencies within
658-
// a given defer block were eagerly references elsewhere in a file,
658+
// a given defer block were eagerly referenced elsewhere in a file,
659659
// thus no dynamic `import()`s were produced.
660660
if (!dependenciesFn) {
661661
tDetails.loadingPromise = Promise.resolve().then(() => {
662+
tDetails.loadingPromise = null;
662663
tDetails.loadingState = DeferDependenciesLoadingState.COMPLETE;
663664
});
664665
return;

0 commit comments

Comments
 (0)