Skip to content

Tests: Disable Vite depsOptimizer discovery in createTestApp#173

Merged
lehni merged 1 commit into
mainfrom
fix/vite-test-no-discovery
Apr 29, 2026
Merged

Tests: Disable Vite depsOptimizer discovery in createTestApp#173
lehni merged 1 commit into
mainfrom
fix/vite-test-no-discovery

Conversation

@lehni
Copy link
Copy Markdown
Contributor

@lehni lehni commented Apr 29, 2026

Written by Claude.

Fixes a Fixture "workerUrl" timeout of 60000ms exceeded during teardown flake hit on programmatic-only Playwright workers (e.g. assets/programmatic/*.ts).

Root cause

Vite's pluginContainer.close() (vite/dist/node/chunks/node.js:30192) does:

async close() {
    if (this._closed) return;
    this._closed = true;
    await Promise.allSettled(Array.from(this._processesing));   // ← hangs here
    await this.hookParallel("buildEnd", ...);                    // never reached
    await this.hookParallel("closeBundle", ...);
}

_processesing contains in-flight resolveId / load / transform calls dispatched by the depsOptimizer's startup scan. When discover.cancel() runs at teardown, the cancel does not propagate to those calls — they stay unsettled and Promise.allSettled waits forever.

Workers that never visit /admin/ (programmatic-only suites) finish their tests fast and tear down while the scan is still in flight, triggering the hang.

Fix

optimizeDeps: { noDiscovery: true, include: [] } — skip the discovery scan entirely. No scan = nothing in flight at teardown = no hang.

Same workaround vitest applies for the same reason: vitest commit e379f64 "fix: disable optimizeDeps when running tests". Closest open vite issue is vite#18224 (p2-edge-case, still open). The maintainers have acknowledged depsOptimizer cleanup is a hole in server.close().

include: [] is a no-op merge against the AdminController's existing include list (assignDeeply on arrays is positional), so explicit pre-bundles still apply.

Verified

10 cold-cache local runs (cleared dito-e2e-vite-cache before each), all clean — no Failed worker and 0 Re-optimizing dependencies messages.

Test plan

  • Run pnpm --filter @ditojs/tests test:e2e cold and confirm no teardown timeout
  • Re-run warm and confirm no regressions

- pluginContainer.close awaits in-flight scan transforms forever (vite 8)
- discover.cancel() at teardown doesn't propagate to dispatched calls
- programmatic-only workers hit the 60s workerUrl fixture timeout
- noDiscovery: true matches vitest's workaround (commit e379f64)
@lehni lehni merged commit 9148b74 into main Apr 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant