Skip to content

test(deflake): run.scm-lite.integration — 1/5 flaky (port & startup race) #47

@Talchain

Description

@Talchain

Context

After deflake phase 1 (PR #46), this test remains flaky at 1/5 failure rate.

Failing File

  • tests/run.scm-lite.integration.test.ts

Root Cause

Port conflicts and startup race conditions causing intermittent failures.

Action Plan

  1. Use ephemeral port: server.listen(0) then read server.address().port
  2. Await readiness: await once(server, 'listening') before sending requests
  3. Serialize the suite: avoid test.concurrent in this file
  4. Ensure full teardown:
    • afterAll closes server, destroys clients
    • await new Promise(r => setTimeout(r, 50)) after close to drain timers
  5. If worker/child process involved: add unique namespace (env suffix) per test and kill on teardown

Definition of Done

  • Test passes 5/5 runs consistently
  • Ephemeral port allocation implemented
  • Proper readiness awaiting
  • Clean teardown with timer drain

Proof Command

for i in {1..5}; do npx vitest run tests/run.scm-lite.integration.test.ts; done

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions