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

Maximum call stack size exceeded when assertion fails with cyclic references of Error.cause #1645

Closed
hi-ogawa opened this issue Oct 7, 2024 · 1 comment · Fixed by chaijs/loupe#82

Comments

@hi-ogawa
Copy link

hi-ogawa commented Oct 7, 2024

chai: 5.1.1
reproduction: https://stackblitz.com/edit/github-caqski-bm1zja?file=repro.mjs

import * as chai from 'chai';

const e = new Error('hello');
e.cause = e;

chai.expect(e).to.equal(123);
// Error: Maximum call stack size exceeded

For the context, we're thinking to expand on Error equality on Vitest vitest-dev/vitest#5876. Most of the logic is implemented on Vitest side, but we still use chai's assertion error message generation. While making test cases with cyclic references, I found that Error: Maximum call stack size exceeded is likely coming from chai as seen in the repro above.

43081j added a commit to chaijs/loupe that referenced this issue Oct 7, 2024
Fixes chaijs/chai#1645

We already handle circular references in objects, but do not do the same
for `Error` objects. This change adds the same `seen` logic to error
inspection as we have in object inspection.
@43081j
Copy link
Contributor

43081j commented Oct 7, 2024

i've fixed this in chaijs/loupe#82

once that lands, I'll bump the version in chai and get a new patch version published

43081j added a commit to chaijs/loupe that referenced this issue Oct 7, 2024
* fix: handle circular refs in errors

Fixes chaijs/chai#1645

We already handle circular references in objects, but do not do the same
for `Error` objects. This change adds the same `seen` logic to error
inspection as we have in object inspection.
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 a pull request may close this issue.

2 participants