Skip to content

RangeError: Maximum call stack size exceeded - when there are large outputs #3060

@nathanmmiller

Description

@nathanmmiller

Describe the bug

When there are very large outputs, picocolors causes a stack overflow.

This is reproducible with this stackblitz: stackblitz [open, run npm install, then npm run test]

Note the following changes I've made in this stackblitz in order to get a huge output to trigger this:

  1. I'm importing a large external library (ag-grid) that I know causes massive DOMs
  2. I'm using react-testing-library
  3. I've set the DEBUG_PRINT_LIMIT env var to 100000.

This is a common use case because react-testing-library usually restricts its output and it's hard to see where in the DOM an issue exists.

However, in this case, the use of picocolors in displaying the error causes a stack overflow:
RangeError: Maximum call stack size exceeded
...
❯ replaceClose node_modules/picocolors/picocolors.js:25:30
❯ replaceClose node_modules/picocolors/picocolors.js:25:30
❯ replaceClose node_modules/picocolors/picocolors.js:25:30
❯ replaceClose node_modules/picocolors/picocolors.js:25:30
❯ Object.red node_modules/picocolors/picocolors.js:17:13
❯ printErrorMessage node_modules/vitest/dist/chunk-node-pkg.f9696901.js:13922:18
❯ printError node_modules/vitest/dist/chunk-node-pkg.f9696901.js:13811:3
❯ Logger.printError node_modules/vitest/dist/chunk-node-pkg.f9696901.js:14026:12
❯ DefaultReporter.printTaskErrors node_modules/vitest/dist/chunk-node-pkg.f9696901.js:11166:29
❯ DefaultReporter.printErrorsSummary node_modules/vitest/dist/chunk-node-pkg.f9696901.js:11111:18
❯ DefaultReporter.reportSummary node_modules/vitest/dist/chunk-node-pkg.f9696901.js:11037:16
❯ DefaultReporter.onFinished node_modules/vitest/dist/chunk-node-pkg.f9696901.js:10898:16
❯ DefaultReporter.onFinished node_modules/vitest/dist/chunk-node-pkg.f9696901.js:12212:17
❯ Vitest.report node_modules/vitest/dist/chunk-node-pkg.f9696901.js:15571:5
❯ async file:/C:/Users/E586213/git/meiji.ronin/node_modules/vitest/dist/chunk-node-pkg.f9696901.js:15372:7
❯ Vitest.runFiles node_modules/vitest/dist/chunk-node-pkg.f9696901.js:15375:12
❯ Vitest.start node_modules/vitest/dist/chunk-node-pkg.f9696901.js:15291:5
❯ startVitest node_modules/vitest/dist/chunk-node-pkg.f9696901.js:22440:5
❯ start node_modules/vitest/dist/cli.js:105:17

Reproduction

This is reproducible with this stackblitz: stackblitz [open, run npm install, then npm run test]

System Info

Reproduced on 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: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^3.1.0 => 3.1.0 
    vitest: ^0.29.2 => 0.29.7 

But I originally found this issue on a windows machine with similar values as above (yarn 1, node16, vitest 0.29.7)

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions