Workers SDK Issue Reports

← Back to Dashboard

#9029 Vitest significantly slower after fix of #6844

Recommendation:KEEP OPEN
Difficulty:medium
Reasoning:

14x performance regression (24s→356s) after v0.7.3. resetModules() line still present in codebase. No fix merged.

Suggested Action:

Make resetModules() conditional (watch mode only) or add config option

Analysis Report

Issue Review: cloudflare/workers-sdk#9029

Summary

Vitest test suite runs 14x slower (24s → 356s) after vitest-pool-workers 0.7.3 due to resetModules() fix for #6844.

Findings

  • Created: 2025-04-22
  • Updated: 2025-05-12
  • Version: vitest-pool-workers 0.7.3 → 0.12.6 (current)
  • Component: vitest-pool-workers
  • Labels: bug, vitest
  • Comments: 1 (reporter workaround)

Key Evidence

  • Reporter identified the specific line causing the issue: packages/vitest-pool-workers/src/worker/lib/cloudflare/test-runner.ts:236
  • The vi.resetModules() call was added to fix #6844 (mocks failing when tests rerun in watch mode)
  • The problematic code is still present in the current codebase at line 236
  • No merged PRs address this performance regression
  • No changelog entries mention a fix for this issue
  • Reporter provided a workaround: vi.spyOn(vitest, "resetModules").mockImplementation(() => undefined as any);
  • Performance impact is severe: 24.95s → 356.40s (14x slowdown)

Recommendation

Status: KEEP OPEN

Reasoning: This is a legitimate performance regression with a clear root cause identified by the reporter. The problematic resetModules() call is still in the codebase at line 236 of test-runner.ts. The issue trades test correctness in watch mode (#6844) for massive performance degradation in all runs.

Action: The maintainers should consider:

  1. Making resetModules() conditional (only in watch mode)
  2. Providing a configuration option to disable this behavior
  3. Investigating alternative solutions that don't impact performance

Notes & Feedback (0)

No notes yet.

Add Note