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

Performance issue when throwing errors that have stackTraceLimit = 0 #6039

Open
6 tasks done
jrmdayn opened this issue Jul 5, 2024 · 2 comments · May be fixed by #6123
Open
6 tasks done

Performance issue when throwing errors that have stackTraceLimit = 0 #6039

jrmdayn opened this issue Jul 5, 2024 · 2 comments · May be fixed by #6123

Comments

@jrmdayn
Copy link

jrmdayn commented Jul 5, 2024

Describe the bug

When setting Error.stackTraceLimit = 0 in a custom error and throwing it inside a test, the time it takes for vitest to display the error is proportional to the size of the object passed (size of the message string).
In the example below, you can change the value of object size and see in the console that it takes more and more time to return. You can also comment the line Error.stackTraceLimit = 0 to see that the problem disappears.
On my machine, vitest just hangs after a certain size and I have to kill the process manually.
Note that I am using an external library that throws errors with a stackTraceLimit of 0, so I do not control this on my end.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-edo7vt?file=test%2Fbasic.test.ts

System Info

from stackblitz:

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 1.6.0 
    vite: latest => 5.3.3 
    vitest: latest => 1.6.0

Used Package Manager

npm

Validations

@AriPerkkio
Copy link
Member

AriPerkkio commented Jul 6, 2024

regexr.com/82i8b

// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/optimal-quantifier-concatenation
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/

image

With const objectSize = 40; in the test case this gets really bad:

@userquin userquin linked a pull request Jul 14, 2024 that will close this issue
6 tasks
@jrmdayn
Copy link
Author

jrmdayn commented Nov 6, 2024

@AriPerkkio @userquin - how can we move forward with PR #6123?
I really appreciate your efforts trying to fix the problem 🙏 🙏

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

Successfully merging a pull request may close this issue.

2 participants