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

mutating the [[Prototype]] of an object will cause your code to run very slowly #51

Closed
cramhead opened this issue Jul 24, 2014 · 2 comments

Comments

@cramhead
Copy link

Question: On Firefox, have the following warning.

TypeError: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create.

The debugger points to CollectionHooks.reassignPrototype. I takes two arguments, i.e. instance and constr, but when I search the code I only find one reference to the function in user-compat.js. It's called with only one parameter, i.e. CollectionHooks.reassignPrototype(Meteor.users);
I'm assuming it gets called or Firefox would not be complaining.

I guess the questions are:

  1. Does the function act as expected, considering the missing prototype?
  2. Could Firefox be outputing the message even thought it's not called, i.e. a parsing check?
  3. Is there an different approach that would not have a warning and performance penalty?
@mizzao
Copy link
Contributor

mizzao commented Jul 24, 2014

This is being done in https://github.com/matb33/meteor-collection-hooks/blob/master/collection-hooks.js#L169.

I recall that @matb33 did this because of #34, and something else I don't really remember. Was it because of interoperability with collection2?

@matb33
Copy link
Collaborator

matb33 commented Jul 24, 2014

Actually it was for meteor-collection-helpers, but it could apply to other packages in the future. We discuss it here: dburles/meteor-collection-helpers#2 (comment)

This is related to how the accounts package instantiates Meteor.users before our package has a chance to hook itself up.

@matb33 matb33 closed this as completed Jul 24, 2014
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

No branches or pull requests

3 participants