Skip to content

Two signal tests in passthrough.test.ts fail when the tool starts more than 600 ms late #1994

Done

Description

@V3RON

src/cli/passthrough.test.ts:82 and :104 wait a fixed 600 ms from the spawn, then signal a node tool that must have installed its handlers by then. A slower start fails both tests with the product correct. Not seen on a real run. Shown by making the tool wait 900 ms before its first statement:

AssertionError: expected 130 to be 40                                     src/cli/passthrough.test.ts:87:26
AssertionError: piped stdin: SIGINT forwarded: expected 130 to be 40      src/cli/passthrough.test.ts:113:81

Found while triaging #1986.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 30, 2026
  2. self-assigned this
    on Nov 30, 2026
  3. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Seen on: test output with a slowed tool. Not seen on a real run; spawnPassthrough is correct.

    Both reported failures are confirmed. On bug/1994-repro the two tests end their title with "when the tool starts late" and delay the tool 900 ms. They fail every run (4 of 4):

    pnpm exec vitest run --project unit src/cli/passthrough.test.ts
    
    AssertionError: expected 130 to be 40                                  src/cli/passthrough.test.ts:90:26
    AssertionError: piped stdin: SIGINT forwarded: expected 130 to be 40   src/cli/passthrough.test.ts:116:81
    Tests  2 failed | 5 passed (7)
    

    Root cause

    Defect in the tests. src/cli/passthrough.test.ts:83 and :102 on main sleep 600 ms from the spawn instead of waiting for the tool's handlers. A signal sent before they exist kills the tool: 128 + SIGINT = 130. The tool's own setTimeout(exit 0, 1500) (:76, :97) is a second race: the signal must arrive within it.

    Simplest fix

    In this test file only: the tool writes a ready file after installing its handlers, and the test waits for it before the signal. The test then removes the file, which replaces the 1500 ms timer: the tool exits 0, 200 ms after it sees the file gone, unless a signal ended it first.

    // tool, after its two handlers
    fs.writeFileSync(ready, ""); setTimeout(() => process.exit(1), 15000); // orphan guard
    const poll = setInterval(() => { if (fs.existsSync(ready)) return; clearInterval(poll); setTimeout(() => process.exit(0), 200) }, 20);
    // test, in both
    await vi.waitFor(() => expect(existsSync(ready)).toBe(true), { interval: 10, timeout: 10_000 });
    /* call our listeners */
    rmSync(ready);
    fix:         7 passed, 5 of 5; tool 0, 300, 3000 ms late: 7 passed
                 src/cli 531 passed; pnpm test:changed 7 passed; pnpm typecheck clean
    broken spawnPassthrough, with the fix:
      no recordVideo translation   expected 41 to be 40
      always forwards SIGINT       terminal stdin: expected 40 to be +0
      never forwards SIGINT        piped stdin: expected +0 to be 40
      never forwards SIGTERM       expected +0 to be 40; terminal stdin: expected +0 to be 41
      no SIGINT listener on a tty  expected [] to have a length of 1
    

    Alternatives rejected

    • A longer sleep: still a race with the host, and slower on every run.
    • The ready file alone, keeping the 1500 ms timer: the signal still races the tool's exit.

    Risk

    • Remove the temp folder in afterEach, so a failed test's tool ends too.
    • A wrongly forwarded SIGINT must be handled within the 200 ms, or the terminal case passes.
    • The commit hook was not run on the fix. Windows skips both tests.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 30, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 30, 2026
  6. self-assigned this
    on Nov 30, 2026
  7. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1997 (#1994)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

  8. added a commit that references this issue on Nov 30, 2026
    9d3dd59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyfast-track

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions