Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http): delay accessing pendingTasks.whenAllTasksComplete #49784

Closed
wants to merge 2 commits into from

Conversation

alan-agius4
Copy link
Contributor

fix(http): delay accessing pendingTasks.whenAllTasksComplete

Accessing pendingTasks.whenAllTasksComplete too early causes the InitialRenderPendingTasks to return a resolved promise too early. This commit changes the way we access whenAllTasksComplete to only happen when the application is stabilized.


fix(core): resolve InitialRenderPendingTasks promise on complete

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.

@alan-agius4 alan-agius4 changed the title When all tasks complete fix(http): delay accessing pendingTasks.whenAllTasksComplete Apr 11, 2023
@alan-agius4 alan-agius4 requested review from AndrewKushnir and removed request for pkozlowski-opensource April 11, 2023 12:20
@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime area: common/http labels Apr 11, 2023
@ngbot ngbot bot modified the milestone: Backlog Apr 11, 2023
@alan-agius4 alan-agius4 force-pushed the whenAllTasksComplete branch 4 times, most recently from 4171dd0 to 78c32f4 Compare April 11, 2023 16:46
@AndrewKushnir
Copy link
Contributor

Presubmit.

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes @alan-agius4 👍

I've left a minor comment, but let's address it in a followup PR (we can proceed with the merge using the current state).

Another quick question (also for a followup): would it be possible to create a couple test cases for this change, so that we don't regress in the future?

Thank you.

const pendingTasksPromise = pendingTasks.whenAllTasksComplete;

Promise.allSettled([isStablePromise, pendingTasksPromise]).then(() => {
isStablePromise.then(() => pendingTasks.whenAllTasksComplete).then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it'd be great to add a comment to mention:

  • why we do the nesting of promises
  • why the APP_INITIALIZER token is used (and the fact that we don't delay the bootstrap, we just subscribe sooner)

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 11, 2023
@angular angular deleted a comment from ngbot bot Apr 11, 2023
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.
Accessing `pendingTasks.whenAllTasksComplete` too early causes the `InitialRenderPendingTasks` to return a resolved promise too early. This commit changes the way we access `whenAllTasksComplete` to only happen when the application is stabilized.
@AndrewKushnir
Copy link
Contributor

FYI I've pushed a rebase to resolve the merge conflict, which happened around the imports section (no actual conflicts in the logic itself). We can reuse previous g3 presubmit (which was "green") and proceed with the merge.

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit f9b821f.

AndrewKushnir pushed a commit that referenced this pull request Apr 11, 2023
Accessing `pendingTasks.whenAllTasksComplete` too early causes the `InitialRenderPendingTasks` to return a resolved promise too early. This commit changes the way we access `whenAllTasksComplete` to only happen when the application is stabilized.

PR Close #49784
AndrewKushnir pushed a commit that referenced this pull request Apr 11, 2023
…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
AndrewKushnir pushed a commit that referenced this pull request Apr 11, 2023
Accessing `pendingTasks.whenAllTasksComplete` too early causes the `InitialRenderPendingTasks` to return a resolved promise too early. This commit changes the way we access `whenAllTasksComplete` to only happen when the application is stabilized.

PR Close #49784
@alan-agius4 alan-agius4 deleted the whenAllTasksComplete branch April 11, 2023 22:21
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common/http area: core Issues related to the framework runtime target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants