Skip to content

stack trace without source maps of external modules #9003

@jendrikw

Description

@jendrikw

Describe the bug

When using preact, error stack traces show a location inside of minified code.

Example:

stack: 'Error: \n' +
    '    at HelloWorld (/home/projects/vitest-tests-browser-examples-mcpuv5wi/src/HelloWorld.tsx:2:9)\n' +
    '    at E (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/preact/dist/preact.mjs:25:9288)\n' +
    '    at O (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/preact/dist/preact.mjs:25:6220)\n' +
    '    at I (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/preact/dist/preact.mjs:25:1839)\n' +
    '    at O (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/preact/dist/preact.mjs:25:6502)\n' +
    '    at render (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/preact/dist/preact.mjs:25:9451)\n' +
    '    at null.<anonymous> (/home/projects/vitest-tests-browser-examples-mcpuv5wi/tests/HelloWorld.test.tsx:6:14)\n' +
    '    at <anonymous> (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/@vitest/runner/dist/index.js:191:11)\n' +
    '    at <anonymous> (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/@vitest/runner/dist/index.js:787:26)\n' +
    '    at <anonymous> (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/@vitest/runner/dist/index.js:1670:22)\n' +
    '    at <anonymous> (https://vitesttestsbrowserexamplesmcpu-hlwm.w-corp-staticblitz.com/blitz.cf284e50.js:31:27828)\n' +
    '    at _0x59a3b6 (https://vitesttestsbrowserexamplesmcpu-hlwm.w-corp-staticblitz.com/blitz.cf284e50.js:31:27787)\n' +
    '    at runWithTimeout (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/@vitest/runner/dist/index.js:1636:10)\n' +
    '    at runTest (file:///home/projects/vitest-tests-browser-examples-mcpuv5wi/node_modules/@vitest/runner/dist/index.js:1343:12)',

It's hard to understand what's going on if the stack trace points to preact.mjs:25:6220. To me, it seems like preact.mjs defines it's source map.

Reproduction

https://stackblitz.com/edit/vitest-tests-browser-examples-mcpuv5wi?file=package.json

System Info

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: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vitest: ^4.0.8 => 4.0.8

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

Labels

p3-minor-bugAn edge case that only affects very specific usage (priority)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions