Skip to content

Commit 2f2ef14

Browse files
alan-agius4AndrewKushnir
authored andcommitted
fix(core): resolve InitialRenderPendingTasks promise on complete (#49784)
Current in the `InitialRenderPendingTasks` when the `collection` size is 0 a new promise is created a the status is changed to completed. This causes the promise that is created during the class initialization phase to never be resolved which causes SSR to hang indefinitely. PR Close #49784
1 parent 6623810 commit 2f2ef14

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/core/src/initial_render_pending_tasks.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ export class InitialRenderPendingTasks implements OnDestroy {
3030
private promise!: Promise<void>;
3131

3232
get whenAllTasksComplete(): Promise<void> {
33-
if (this.collection.size > 0) {
34-
return this.promise;
33+
if (this.collection.size === 0) {
34+
this.complete();
3535
}
36-
return Promise.resolve().then(() => {
37-
this.completed = true;
38-
});
36+
37+
return this.promise;
3938
}
4039

4140
completed = false;
@@ -66,14 +65,17 @@ export class InitialRenderPendingTasks implements OnDestroy {
6665

6766
this.collection.delete(taskId);
6867
if (this.collection.size === 0) {
69-
// We've removed the last task, resolve the promise.
70-
this.completed = true;
71-
this.resolve();
68+
this.complete();
7269
}
7370
}
7471

7572
ngOnDestroy() {
76-
this.completed = true;
73+
this.complete();
7774
this.collection.clear();
7875
}
76+
77+
private complete(): void {
78+
this.completed = true;
79+
this.resolve();
80+
}
7981
}

0 commit comments

Comments
 (0)