Describe the bug
dist/workerNew.js (and workerLegacy.js) mutates every non-own reporter with:
p.reporters.forEach(e => { e instanceof Z || (e.onUserConsoleLog = void 0) });
That assigns undefined as an instance property, shadowing BaseReporter.prototype.onUserConsoleLog. When test.silent: 'passed-only' is set and a failing test has captured console output, vitest's inherited BaseReporter.logFailedTask calls this.onUserConsoleLog(log, "failed") unguarded and throws TypeError: this.onUserConsoleLog is not a function. The dispatcher catches it and prints Unhandled Reporter Error for every failed test/suite/module — and the failing test's captured logs (which passed-only exists to surface) are silently dropped.
Suggested fix: don't delete the inherited method. Either assign a no-op (e.onUserConsoleLog = () => {}) or override e.shouldLog = () => false to suppress the duplicate terminal output while keeping the prototype contract intact.
Verified: same vitest config run from the CLI (no extension) does not crash — onUserConsoleLog is resolvable. The crash only appears when the extension's mutation has run.
Environment: vitest.explorer@1.50.4, vitest@4.1.6 (also reproduced on 4.0.18; same pattern present on vitest main).
Expected behavior
When silent: 'passed-only' is set and a failing test has captured console output, that captured output should be replayed under the failure banner — same as it is when running vitest directly from the CLI. Instead, the reporter dispatch crashes with Unhandled Reporter Error and the logs are silently dropped.
Reproduction
Minimal repro repo with deterministic forced repro + analysis: https://github.com/rhwinter/vitest-loggingError
git clone https://github.com/rhwinter/vitest-loggingError
cd vitest-loggingError
npm install
npm run repro:forced
broken-reporter.js mirrors the extension's exact mutation (reporter.onUserConsoleLog = undefined on a DefaultReporter instance). Stack trace produced is frame-for-frame identical (modulo reporter class name) to the one we see from the extension:
TypeError: this.onUserConsoleLog is not a function
❯ ExtensionShadowedReporter.logFailedTask …/index.UpGiHP7g.js:2239:78
❯ ExtensionShadowedReporter.onTestCaseResult …/index.UpGiHP7g.js:2229:50
❯ ExtensionShadowedReporter.onTestCaseResult …/index.UpGiHP7g.js:3123:9
❯ Vitest.report / TestRun.reportEvent / TestRun.updated / Proxy.onTaskUpdate
Output
The only visible side-effect here is the premature WebSocket close at the end of the run.
[10:19:03 PM] [API] Filtering projects: repro
[INFO 10:19:03 PM] [API] Running Vitest v4.1.6 (vitest-loggingError/vitest.config.js) with "/Users/.../.local/state/fnm_multishells/69887_1779131127156/bin/node /Users/.../.vscode/extensions/vitest.explorer-1.50.4/dist/worker.js"
[10:19:03 PM] Enqueuing "failing test with console output → reporter crashes"
[INFO 10:19:03 PM] Running 1 file(s) with name pattern: ^\s?failing test with console output → reporter crashes$
[INFO 10:19:04 PM] [DECOR] Reset all decorations.
[10:19:04 PM] No task result for "repro.test.js [repro]", ignoring
[10:19:04 PM] Enqueuing "failing test with console output → reporter crashes"
[10:19:04 PM] No errors found for "repro.test.js [repro]"
[10:19:04 PM] Marking "failing test with console output → reporter crashes" as failed with 1 errors
[10:19:04 PM] No errors found for "repro.test.js [repro]"
[10:19:04 PM] Ending test run repro.test.js
[10:19:04 PM] Disposing test runner
[10:19:04 PM] [API] Vitest WebSocket connection closed, cannot call RPC anymore.
Extension Version
vitest.explorer@1.50.4
Vitest Version
vitest@4.1.6 (also reproduced on 4.0.18; same code path on main/5.0.0-beta.2)
Validations
Describe the bug
dist/workerNew.js(andworkerLegacy.js) mutates every non-own reporter with:That assigns
undefinedas an instance property, shadowingBaseReporter.prototype.onUserConsoleLog. Whentest.silent: 'passed-only'is set and a failing test has captured console output, vitest's inheritedBaseReporter.logFailedTaskcallsthis.onUserConsoleLog(log, "failed")unguarded and throwsTypeError: this.onUserConsoleLog is not a function. The dispatcher catches it and printsUnhandled Reporter Errorfor every failed test/suite/module — and the failing test's captured logs (whichpassed-onlyexists to surface) are silently dropped.Suggested fix: don't delete the inherited method. Either assign a no-op (
e.onUserConsoleLog = () => {}) or overridee.shouldLog = () => falseto suppress the duplicate terminal output while keeping the prototype contract intact.Verified: same vitest config run from the CLI (no extension) does not crash —
onUserConsoleLogis resolvable. The crash only appears when the extension's mutation has run.Environment:
vitest.explorer@1.50.4,vitest@4.1.6(also reproduced on4.0.18; same pattern present on vitestmain).Expected behavior
When
silent: 'passed-only'is set and a failing test has captured console output, that captured output should be replayed under the failure banner — same as it is when running vitest directly from the CLI. Instead, the reporter dispatch crashes withUnhandled Reporter Errorand the logs are silently dropped.Reproduction
Minimal repro repo with deterministic forced repro + analysis: https://github.com/rhwinter/vitest-loggingError
broken-reporter.jsmirrors the extension's exact mutation (reporter.onUserConsoleLog = undefinedon aDefaultReporterinstance). Stack trace produced is frame-for-frame identical (modulo reporter class name) to the one we see from the extension:Output
Extension Version
vitest.explorer@1.50.4
Vitest Version
vitest@4.1.6 (also reproduced on 4.0.18; same code path on main/5.0.0-beta.2)
Validations