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

TypeError: Cannot read properties of undefined (reading 'stacks') #654

Closed
6 tasks done
skyrpex opened this issue Jan 28, 2022 · 3 comments · Fixed by #660
Closed
6 tasks done

TypeError: Cannot read properties of undefined (reading 'stacks') #654

skyrpex opened this issue Jan 28, 2022 · 3 comments · Fixed by #660

Comments

@skyrpex
Copy link

skyrpex commented Jan 28, 2022

Describe the bug

The library https://github.com/colinhacks/zod throws a ZodError when the parsing fails. Seems like this error is not well handled by vitest and crashes during a call to parseStacktrace.

Reproduction

https://stackblitz.com/edit/node-xzljid?file=test%2Fbasic.test.ts&view=editor

System Info

System:
    OS: Linux 5.13 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (20) x64 Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz
    Memory: 18.66 GB / 31.27 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.3 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 97.0.4692.99
    Firefox: 96.0

Used Package Manager

yarn

Validations

@Demivan
Copy link
Member

Demivan commented Jan 29, 2022

Cause of the problem: Zod error cannot be serialized using serializeError.

@wieringen
Copy link

wieringen commented May 15, 2022

@patak-dev, I believe this error is back. I'm using vitest together with testing-library and jsdom. Some of my tests fail with: TypeError: Cannot read properties of undefined (reading 'stacks'). I narrowed the issue down to vitest not being able to handle jsdom/domexception errors. I have reproduced the issue by simply throwing a domexception error inside a test.

import DOMException from "domexception";
import {it, describe} from 'vitest'

describe('The Index Page', () => {
  it('should display content if no params are given', () => {
    throw new DOMException("Something went wrong", "BadThingsError");
  })
})

@ocodista
Copy link

Same happens with crypto-js.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants