-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
🐛 Bug: Comparing buffers hangs when computing the diff report #1624
Comments
I tested it right now(with a very small files), and it work pretty good. here's the output: Testing buffer equality
1) should not take foreveeeeeer
0 passing (6ms)
1 failing
1) Testing buffer equality should not take foreveeeeeer:
AssertionError: expected <Buffer 66 6f 6f 0a> to deeply equal <Buffer 62 61 72 0a>
+ expected - actual
[
+ 98
+ 97
+ 114
- 102
- 111
- 111
10
] Are you dealing with large files(=buffers) @astorije ? |
Hi @a8m, thanks for answering! Both files are PNG images, one is 20K, the other one is 40K, so too large to paste in Google Translate, but not large enough to expect my Core i7 quad core to hang for 10 minutes... :-/ Could you try with similar images, maybe? |
OK, I get the point. but how this related to mocha? |
@astorije Rather than comparing such large buffers, can you compare their checksums using something like |
Good point. |
Hi guys, I don't want to show the difference, but it's the default behavior when running the simple test case I pasted above. Comparing a checksum is doable, but that would obscure a tiny bit the tests, and I'd like to avoid that for simple object comparison. Is there a way the code above can be used without displaying the diff (nor hiding it by default for all tests)? |
@a8m, I see this as related to mocha because I wasn't expecting a short test case to completely hang. I would have expected either some sort of a timeout or the diff disabled on such cases. Does that make sense? |
Yes, this is just a patch, but it should work. try {
expect(x).to.equal(y)
} catch(e) {
e.showDiff = false
throw e
} |
We should suppress |
this is something that changes depending on the machine(the cpu, not the size), maybe |
@a8m, a timeout seems like a good way to go, but not the same timeout that is used for each assertion/test. |
I'm not sure. How helpful is a huge buffer diff? |
I am a bot that watches issues for inactivity. |
Had a similar issue to this with chai-subset. The test itself didn't timeout, but when mocha tried to print the failure at the end, it failed to do so and completely stalled/halted. Mocha never terminated. |
I can confirm this also happens when comparing a large object structure as well,
The provided workaround works but it would be nice if the default behavior would not just cause it to hang. |
Hi are we looking to fix the issue, as i am also facing the same issue and not able to generate a diff report for my consolidated api diff regression suit. Would appreciate, if someone can pick up this. |
I am having the very same issue as #1433 mocha 2.2.1 and chai 2.1.1. When 2 buffers are not equal, the diff computation hangs and CPU gets crazy.
Any chance of a regression bug here?
Sample code to reproduce this:
At this point of writing, I am unclear if this issue comes from mocha or from chai, though...
The text was updated successfully, but these errors were encountered: