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

Do not invoke getters in walk #1059

Merged
merged 1 commit into from
Jun 5, 2016
Merged

Conversation

mantoni
Copy link
Member

@mantoni mantoni commented Jun 3, 2016

Purpose (TL;DR) - mandatory

When stubbing a prototype, the walk implementation accesses getters to obtain the value of each property to pass it to the iterator function. This value is not needed by any of the iterator implementations anymore, but invoking the getter may have side effects or throw exceptions.

Solution - optional

With this change, values are no longer obtained from the objects. It keeps the code to pass a different target object to the iterator which allows to obtain the value in the iterator implementation if necessary.

It turned out that none of the iterator functions passed to walk actually used the value.

How to verify - mandatory

var redis = require("redis");
var sinon = require("sinon");

sinon.createStubInstance(redis.RedisClient); // throws without this change

When stubbing a prototype, the `walk` implementation accesses getters to
obtain the value of each property to pass it to the iterator function.
This value is not needed by any of the iterator implementations anymore,
but invoking the getter may have side effects or throw exceptions.

With this change, values are no longer obtained from the objects. It
keeps the code to pass a different target object to the iterator which
allows to obtain the value in the iterator implementation if necessary.
@mantoni
Copy link
Member Author

mantoni commented Jun 3, 2016

Note: The browser tests are still failing due to our SauceLabs account being configured with zero concurrent VMs. I’ve email their support and hope to get the issue resolved soon.

@fatso83
Copy link
Contributor

fatso83 commented Jun 5, 2016

Merging this as the browser tests are failing anyway these days.

@fatso83 fatso83 merged commit 3f0787f into master Jun 5, 2016
@fatso83 fatso83 deleted the do-not-invoke-getters-in-walk branch June 5, 2016 19:01
@kkamkou
Copy link

kkamkou commented Jun 13, 2016

Thank you for the commit. @fatso83, is it possible to cpeek this commit and release a new minor version?

@fatso83
Copy link
Contributor

fatso83 commented Jun 13, 2016

@mantoni and @fearphage : should we release a new minor version, or try to get #1040 fixed first?

@mantoni
Copy link
Member Author

mantoni commented Jun 13, 2016

@fatso83 I'm currently linking sinon locally until this fix is released, so no pressure for me personally.

@fatso83
Copy link
Contributor

fatso83 commented Jun 13, 2016

@kkamkou : if you don't want to wait for a minor fix you can just link to the relevant commit in your package.json. See the NPM docs in the Github section for details.

@kkamkou
Copy link

kkamkou commented Jun 13, 2016

@fatso83 already. In the same time we're using versioneye, therefore version tracking is broken for one particular repo.

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.

3 participants