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

assert.deepEqual hangs when comparing arrays if the array prototype was modified by Opal #1153

Closed
s-leroux opened this issue Apr 9, 2018 · 4 comments

Comments

@s-leroux
Copy link
Contributor

s-leroux commented Apr 9, 2018

Opal is a Ruby to JS converter. opal-runtime by @Mogztter is a helper library providing the runtime environment to run Ruby->JS converted programs.

Apparently, it modifies the prototype of the standard objects in such a way assert.deepEqual hangs (presumably on a circular reference):

> require('opal-runtime')
> assert = require('chai').assert
> assert.deepEqual([1,2,3], [1,2]);
## Hang here

I assume other libraries modifying the standard object's prototype in a similar way could cause Chai to hang too.

Tested with node v8.9.4, opal-runtime 1.0.1 and chai 4.1.2

@demurgos
Copy link

demurgos commented Apr 9, 2018

Maybe related to chaijs/deep-eql#51. (Edit: Probably not, see below)

A fix would be to use Function#apply instead of the methods on the objects.

@s-leroux
Copy link
Contributor Author

s-leroux commented Apr 9, 2018

Maybe @demurgos. Maybe not.

I tried to follow the code with the debugger. It does not seem to be stuck in an infinite loop. But I also noticed Chai found 850 visible properties on arrays and 800 on functions. So the issue might "just" be caused by a combinatorial explosion.

@s-leroux
Copy link
Contributor Author

s-leroux commented Apr 9, 2018

Related to #1109

@keithamus
Copy link
Member

Hey @s-leroux thanks for the issue.

I'm sure this is actually a duplicate of #1109. assert.deepEqual works with circular references, so it is likely that the issue is with loupe, as mentioned in #1109. I'll close this one, but thanks for filing this issue and please don't hesitate to open any new ones if you find anything new!

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