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] Ensure App.visit resolves when rendering completed. #16087

Merged
merged 2 commits into from
Jan 8, 2018

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Jan 8, 2018

Creates a new internal method (named renderSettled) that returns a promise which will resolve when rendering has settled. Settled in this context is defined as when all of the tags in use are "current" (e.g. renderers.every(r => r._isValid())). When this is checked at the end of the run loop, this essentially guarantees that all rendering is completed.

Prior to this change, rendering was not guaranteed to have been completed before the promise returned from the visit API had resolved (yes, even though afterRender queue was being used). With these changes no additional delay is added, but we have still ensured that all rendering is completed...

Fixes #16059

Prior to this change, rendering was not guaranteed to have been
completed before the promise returned from the `visit` API had resolved.

With these changes no additional delay is added, but we have still
ensured that all rendering is completed.
@rwjblue rwjblue merged commit db1f29f into emberjs:master Jan 8, 2018
@rwjblue rwjblue deleted the visit-async branch January 8, 2018 21:54
run.schedule('afterRender', null, resolve, this);
});
// Ensure that the visit promise resolves when all rendering has completed
return renderSettled().then(() => this);
Copy link
Contributor

@snewcomer snewcomer Apr 12, 2019

Choose a reason for hiding this comment

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

@rwjblue Sorry to bring up something old, but seeing some memory leaks in fastboot related to retaining the Container. Is it necessary to return this in the callback? I think it is, but wondering if it is possible this never resolves but the app still is rendered.

What I'm worries about is never reaching a settled state or resolving, thus every request that comes in builds a new instance (w/ shoebox data) and the eventually swamps the server's heap.

Copy link
Contributor

Choose a reason for hiding this comment

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

On 3.5 right now

Copy link
Contributor

@snewcomer snewcomer Apr 12, 2019

Choose a reason for hiding this comment

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

Screenshot 2019-04-12 at 13 58 39

Screenshot 2019-04-12 at 15 25 25
Screenshot 2019-04-12 at 15 12 49

some more info. I'm wondering if we need to "settle" the deferred promise when shouldRender is false....So not this block but the above block.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really follow. Can you file an issue with a reproduction?

Copy link
Contributor

@snewcomer snewcomer Apr 17, 2019

Choose a reason for hiding this comment

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

@rwjblue - We found it. Well @Serabe found it so I'll let him explain beyond this short answer! In an adapter, he found that headers as a computed was potentially leaking the container thus not allowing V8 to not gc anything. The problem wasn't necessarily ajax/najax/node-fetch but the way we configured our adapter.

// adapter
headers: computed(function() {

to a getter fixed it.

// adapter
get headers() {

We are on 3.5 and still investigating

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.

Fix visit() promise resolution
3 participants