Skip to content

roots.test times out at 5 s under full-suite load (cold server import) #370

Closed

Description

@TMHSDigital

Summary

The "client roots over MCP" test sometimes times out at vitest's default 5 s during a full npm test run, and it passes when run on its own. This makes a full local run look red when nothing is broken.

Where

  • src/__tests__/roots.test.ts:123 ("reads roots after initialize, refuses outputs outside them, and follows list_changed")

Details

The test does all of its setup inside the test body, which runs under the default 5 s timeout:

it("reads roots after initialize, refuses outputs outside them, and follows list_changed", async () => {
  const { createServer } = await import("../server.js");
  ...
  await Promise.all([server.connect(serverT), client.connect(clientT)]);

The cold import("../server.js") loads and registers every tool module. Under full-suite load on Windows that alone can take seconds. Other tests that start the server (startRecording.test.ts, recordingControlHandlers.test.ts) import it in beforeAll instead, which has a longer hook timeout.

Seen twice in a row on 2026-11-18 at f88f124 and 6db59a6:

FAIL  src/__tests__/roots.test.ts > client roots over MCP > reads roots after initialize, ...
Error: Test timed out in 5000ms.

npx vitest run src/__tests__/roots.test.ts passes (17 tests).

Impact

A full local npm test fails now and then for no real reason, so contributors rerun it or ignore real failures. CI has not been hit so far, but the Windows runners are slower than a desktop.

Suggested fix

Move the createServer import (and, if possible, the server and client connect) into a beforeAll, or give this test an explicit timeout, as the PowerShell-backed tests in sessions.test.ts have (30 s).

Acceptance criteria

  • The test no longer runs a cold server import under the 5 s per-test timeout.
  • npm test passes several runs in a row on Windows without this test timing out.

Getting started

  • Relevant files: src/__tests__/roots.test.ts
  • How to run tests: npm test, or npx vitest run src/__tests__/roots.test.ts

Filed by repo-audit/fix-issues at 6db59a6. Severity: low. Effort: S. audit-key: testing|src/__tests__/roots.test.ts|client roots over MCP

Activity

  1. added
    good first issue
    priority: low
    testing
    effort: small
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: smallgood first issuepriority: lowtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions