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

Regression: Error when matching message body #1713

Closed
MacMcIrish opened this issue Sep 10, 2019 · 6 comments · Fixed by #1714
Closed

Regression: Error when matching message body #1713

MacMcIrish opened this issue Sep 10, 2019 · 6 comments · Fixed by #1714
Labels

Comments

@MacMcIrish
Copy link

What is the expected behavior?
To not crash on message body matching if body doesn't match.

What is the actual behavior?
Crashing on message body matching if message body has same count of keys, but different keys.

Possible solution
Go back to using deep-equal npm package. There was a PR here that introduced custom deepEqual logic that is not good enough.
If two objects have the same count of keys but not the same keys, it tries to extract the keys on undefined and crashes, making debugging hard to impossible.

How to reproduce the issue

Runkit: Link

Having problem producing a test case? Try and ask the community for help. If the test case cannot be reproduced, the Nock community might not be able to help you.

Does the bug have a test case?

Versions

Software Version(s)
Nock 11.3.2
Node 10.15.3
@simlu
Copy link

simlu commented Sep 10, 2019

This regression is unfortunately very impacting for us. Would be great to get a quick response! Thank you very much for all the hard work!

paulmelnikow added a commit that referenced this issue Sep 10, 2019
When matching objects with the same number of keys but different keys,
should not match instead of crashing.

Close #1713
paulmelnikow added a commit that referenced this issue Sep 10, 2019
When matching objects with the same number of keys but different keys,
should not match instead of crashing.

Close #1713
@paulmelnikow
Copy link
Member

Thanks for the test case!

@paulmelnikow
Copy link
Member

Can you confirm the fix in #1714?

@MacMcIrish
Copy link
Author

@paulmelnikow I can confirm that #1714 will fix the issue for now. Thank you for the quick response!

Should bringing deep-equal (which is a very popular and maintained package) back into the project be considered? There may be more edge cases not considered with the custom utility.

paulmelnikow added a commit that referenced this issue Sep 12, 2019
When matching objects with the same number of keys but different keys, should not match instead of crashing.

Close #1713
@paulmelnikow
Copy link
Member

On one hand I agree it's better to pull in a library rather than solve problems over and over again. On the other side, a lot of what makes deep-equal complicated seems to be its focus on performance, which is not a big consideration in nock.

This particular bug was very shallow, though I'd say we should consider reverting to deep-equal if we find more subtle edge-case bugs.

/cc @mastermatt, I'd be curious your thoughts.

@nockbot
Copy link
Collaborator

nockbot commented Sep 12, 2019

🎉 This issue has been resolved in version 11.3.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants