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 release] Prevent triggering V8 memory leak bug through registry / resolver access. #12666

Merged
merged 1 commit into from
Dec 2, 2015

Conversation

dgeb
Copy link
Member

@dgeb dgeb commented Dec 1, 2015

This fix changes the expectations of Registry to accept a resolver
that’s an object with a resolve method instead of a straight function.

This allows us to avoid closing over access to a resolver object inside
a function. It also allows us to avoid setting functions which shadow
prototype functions unnecessarily.

Setting Registry#resolver to a function is still allowed but
deprecated, regardless of whether it’s through a constructor option or
via an instance override. The resolver function will be converted into
an object with a resolve method and will present a single deprecation
warning on first access.

This fix also eliminates the need for application instances to override
their registry’s normalizeFullName and makeToString methods.
Instead, the fallback registry will be checked when evaluating these
methods before returning the defaults. Again, this avoids the need to
override instance functions that shadow prototype functions.

[Fixes #12618]

/cc @rwjblue @stefanpenner

@dgeb dgeb force-pushed the disentangle-registry-hooks branch from a1e2dc9 to 52bf722 Compare December 1, 2015 21:20
let resolved;

if (registry.resolver) {
if (typeof registry.resolver === 'function') {
Copy link
Member

Choose a reason for hiding this comment

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

Since registry.resolver is already taken care of in Registry's constructor, we should be able to remove this extra conditional. I do not believe that changing the resolver after registry creation is a thing we should support...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll remove this check and the corresponding test.

@rwjblue
Copy link
Member

rwjblue commented Dec 1, 2015

Looks good other than that one comment about lazily assigning resolver function.

…ry / resolver access.

This fix changes the expectations of Registry to accept a `resolver`
that’s an object with a `resolve` method instead of a straight function.

This allows us to avoid closing over access to a resolver object inside
a function. It also allows us to avoid setting functions which shadow
prototype functions unnecessarily.

Setting `Registry#resolver` to a function is still allowed through a
constructor option. The `resolver` function will be converted into
an object with a `resolve` method and will result in a single deprecation
warning.

This fix also eliminates the need for application instances to override
their registry’s `normalizeFullName` and `makeToString` methods.
Instead, the fallback registry will be checked when evaluating these
methods before returning the defaults. Again, this avoids the need to
override instance functions that shadow prototype functions.

[Fixes emberjs#12618]
@dgeb dgeb force-pushed the disentangle-registry-hooks branch from 52bf722 to 529bfc3 Compare December 1, 2015 22:26
@dgeb
Copy link
Member Author

dgeb commented Dec 1, 2015

Ok, thanks for the review @rwjblue. I just eliminated the ability to lazily assign resolver as a function (which can now only be done through the constructor).

@rwjblue
Copy link
Member

rwjblue commented Dec 2, 2015

We still need confirmation from @stefanpenner that this fixes the leak he reported in #12618, but this is still a good refactor (and replaces some fairly gnarly code!) so I'm going to land this into canary + beta. Once confirmed RE: the leak (and that we don't introduce issues with this change into beta/canary) we can pull into release branch (currently 2.2.x).

rwjblue added a commit that referenced this pull request Dec 2, 2015
[BUGFIX release] Prevent triggering V8 memory leak bug through registry / resolver access.
@rwjblue rwjblue merged commit 3d1cf7b into emberjs:master Dec 2, 2015
@marcoow
Copy link
Contributor

marcoow commented Dec 7, 2015

I guess this requires changes to ember-test-helpers setResolver? Currently this change breaks the Ember Simple Auth build (https://travis-ci.org/simplabs/ember-simple-auth/jobs/94633282) with TypeError: registry.resolver.resolve is not a function at https://github.com/dgeb/ember.js/blob/529bfc3bbfa1c1a96d51a085fcc6394101d8ea6f/packages/container/lib/registry.js#L769.

Would be happy to fix that if you guys can point me in the right direction - I'm not really sure where to start yet…

@rwjblue
Copy link
Member

rwjblue commented Dec 7, 2015

@marcoow - We are tracking that issue over in ember-test-helpers emberjs/ember-test-helpers#126 and emberjs/ember-test-helpers#127. Hoping to get a fix out today...

@marcoow
Copy link
Contributor

marcoow commented Dec 7, 2015

@rwjblue: great; let me know if I can help!

@poteto
Copy link

poteto commented Dec 7, 2015

I'm not sure if you prefer if I created an issue for it, but just to add another instance of the bug report for adopted-ember-addons/ember-metrics#55. For context, I worked through with @rwjblue on refactoring deprecated use of lookupFactory through setting { instantiate: false } on registerOptionsForType in the new getOwner API.

Tests are only failing in beta and canary.

screenshot 2015-12-07 12 11 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.

Memory on acceptance tests on ember 1.13.10+
4 participants