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

[BUGFIX beta] Avoid run.next in app.visit resolve handler. #14591

Merged
merged 1 commit into from
Nov 9, 2016

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Nov 8, 2016

The prior comment has been pointed to by a few different people in the FastBoot team meetings so I decided to dig into exactly what the TODO was talking about. Specifically, why do we need a run.next before resolving the visit promise?

The answer is basically that the router.handleURL transition promise being resolved does not actually guarantee that rendering is completed. Since the renderer schedules the actual revalidation and rendering into the render queue, we must wait for that to complete before resolving the promise.

This commit explains that in the inline comments, and changes the implementation to use run.schedule('afterRender', ....) instead of run.next (since resolving "after rendering is complete" is what we actually care about).

@rwjblue
Copy link
Member Author

rwjblue commented Nov 8, 2016

/cc @chancancode since the original comment was added in #12394.

// a scheduled revalidation (into the `render` queue) in the Renderer.
//
// This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed.
run.schedule('afterRender', null, resolve, this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this fine if the app is being visited in routing-only mode on server side?

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting! I hadn't thought of that when reviewing this, but you are correct when shouldRender is false we can just return this; right away I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup basically stop the execution after the actions queue is flushed.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kratiahuja - Updated

@rwjblue rwjblue force-pushed the cleanup-visit-comments branch from 32a7966 to 6630237 Compare November 8, 2016 19:40
The prior comment has been pointed to by a few different people in the
FastBoot team meetings so I decided to dig into exactly what the TODO
was talking about. Specifically, why do we need a `run.next` before
resolving the visit promise?

The answer is basically that the `router.handleURL` transition promise
being resolved does not actually guarantee that rendering is completed.
Since the renderer schedules the actual revalidation and rendering into
the `render` queue, we must wait for that to complete before resolving
the promise.

This commit explains that in the inline comments, and changes the
implementation to use `run.schedule('afterRender', ....)` instead of
`run.next` (since resolving "after rendering is complete" is what we
actually care about). It also avoids waiting at all when `shouldRender:
false` is passed into the `visit` API (since there is nothing to do in
that case).
@rwjblue rwjblue merged commit 8c8062a into master Nov 9, 2016
@rwjblue rwjblue deleted the cleanup-visit-comments branch November 9, 2016 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants