vitest-dev/vitest · error · Error

Orchestrator not found for session ${sessionId}. This is a b

Error message

Orchestrator not found for session ${sessionId}. This is a bug in Vitest. Please, open a new issue with reproduction.

What it means

Internal assertion in BrowserPool.getOrchestrator: a sessionId was used to dispatch a test, but no orchestrator is registered for it in project.browser.state.orchestrators. Orchestrators (one per browser tab) are created during page setup and removed on teardown, so a lookup miss means the session's lifecycle was not tracked correctly — a framework bug.

Source

Thrown at packages/vitest/src/node/pools/browser.ts:323

      const concurrencyId = sessions.getSession(id)?.concurrencyId
      if (concurrencyId) {
        used.add(concurrencyId)
      }
    }
    let concurrencyId = 1
    while (used.has(concurrencyId)) {
      concurrencyId++
    }
    if (session) {
      session.concurrencyId = concurrencyId
    }
    return concurrencyId
  }

  private getOrchestrator(sessionId: string) {
    const orchestrator = this.orchestrators.get(sessionId)
    if (!orchestrator) {
      throw new Error(`Orchestrator not found for session ${sessionId}. This is a bug in Vitest. Please, open a new issue with reproduction.`)
    }
    return orchestrator
  }

  private finishSession(sessionId: string): void {
    this.readySessions.add(sessionId)

    // the last worker finished running tests
    if (this.readySessions.size === this.orchestrators.size) {
      this._otel.span.end()
      this._promise?.resolve()
      this._promise = undefined
      debug?.('[%s] all tests finished running', sessionId)
    }
    else {
      debug?.(
        `did not finish sessions for ${sessionId}: |ready - %s| |overall - %s|`,
        [...this.readySessions].join(', '),

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Report as a Vitest bug with reproduction (browser config + the failing test).
  2. Retry the run — transient browser disconnects (headless browser crash) can surface this.
  3. Reduce browser.maxWorkers to 1 to rule out a multi-tab orchestrator tracking race.
  4. Ensure the browser provider and Playwright/WebDriverIO versions are compatible with your Vitest version.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await vitest.start()
} catch (e) {
  if (e.message.includes('Orchestrator not found for session')) {
    console.error('Browser orchestrator race — retry; if persistent, report as a bug.')
  }
  throw e
}

Prevention

When it happens

Trigger: runNextTest or finishSession calls getOrchestrator(sessionId) at packages/vitest/src/node/pools/browser.ts:321-323, but the orchestrator for that sessionId was already cleaned up or never registered (e.g. a race between session teardown and a queued file dispatch).

Common situations: Browser tab crashes or disconnects mid-run; rapid test re-runs in watch mode; custom orchestrator lifecycle handling; a regression in session/worker tracking across versions.

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/f1be5c4c8f871dff.json. Report an issue: GitHub.