deepEqual should not infinitely recurse an infinite lazy getter chain
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Description
Tell us about your runtime:
- QUnit version: 2.7.1
- What environment are you running QUnit in? (e.g., browser, Node): Browser
- How are you running QUnit? (e.g., script, testem, Grunt): Script
What are you trying to do?
Code that reproduces the problem:
https://jsfiddle.net/bzomqak8/11/
class Foo {
constructor(a = 1) {
this.a = a;
}
}
Object.defineProperty(Foo.prototype, 'b', {
enumerable: true,
get() {
return new Foo(this.a + 1);
}
})
QUnit.test("hello test", function(assert) {
assert.deepEqual(new Foo(), new Foo());
});
If you have any relevant configuration information, please include that here:
What did you expect to happen?
I expected QUnit to not compare computed properties.
What actually happened?
QUnit compares computed properties by using a for..in loop which (due to BFS) recurses infinitely without ever hitting a stack limit.
This is a minimal reproduction extracted from one of our Ember apps. In the actual app we use an Ember.Object and a computed property instead of the code above, but the effect is the same.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at QUnit's deepEqual entry point and reproduce the case from the linked jsfiddle using the Foo getter chain shown in the issue. Done means the comparison terminates instead of recursing indefinitely and handles the computed property according to the reported expectation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100