Skip to content

flaky: console Screen tab test times out waiting for capture close #1219

Closed

Description

@V3RON

e2e/console/screen.spec.ts:180 "the device drawer's Screen tab › opens on Details with no capture, starts one and paints it on Screen, closes it on Details or closing the drawer, and keeps it when the device is leased" failed once in CI run 41510787354 (PR #1210, commit d4e958e, Console 2/4).

Error: logReached(dir, "closed", 1) at screen.spec.ts:251 timed out: the daemon did not log "closed" within 10 s of the Details click.

It passed 4 of 4 runs locally (Chromium, --repeat-each=3 --workers=3) and passed in CI on the next head (dedb9f8). The Details-click and capture-close part of the test is unchanged from the merge-base.

Written by an agent.

Activity

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

    @V3RON
    ContributorAuthor

    Reproduction

    This is a defect in the test's capture stand-in, not in the daemon. The capture does stop, but the stand-in does not log "closed" when its stdout reader goes away before its stdin ends.

    e2e/console/screen-capture.test.ts on bug/1219-repro, "the console lane's capture program › logs closed when its stdin ends and when its reader goes away before its stdin ends":

    pnpm test:e2e e2e/console/screen-capture.test.ts
    
    AssertionError: expected { …(2) } to deeply equal { …(2) }
        "reader goes away first": [
          "opened",
    -     "closed",
        ],
    

    Root cause

    e2e/console/screen-capture.ts:62: process.stdout.on("error", () => process.exit(0)) exits without writing closed. Only the stdin end handler (line 56) writes it. When a viewer leaves, two things race to stop the capture. One is the abort listener (src/stream/worker-link.ts:66, which ends stdin). The other is the body's cancel (src/stream/feed.ts:103-105), which destroys the child's stdout before feed.close() ends stdin. If the stand-in's 100 ms write timer fires in that gap, it gets EPIPE and exits silently. logReached(dir, "closed", 1) then waits out its 10 s. The real capture program treats EPIPE as a normal stop (vendor/screen-capture/Sources/SimlockCapture/Options.swift:137), so the daemon's order is fine. The lane's witness only misses this kind of stop.

    Simplest fix

    In the program writeCaptureProgram writes, make the stdout error handler appendFileSync(LOG, "closed\n") before process.exit(0). I tried this locally: the reproduction passes.

    Alternatives rejected

    • Close stdin before cancelling stdout in followedBy: the abort listener and the body cancel still race, and the child can still write first.
    • Raise logReached's timeout: the stand-in never logs, so no wait is long enough.

    Risk

    • After the fix, a capture that dies on EPIPE for some other reason also counts as closed. That is acceptable, because the real tool ends the same way.
    • The CI run kept no trace, so this cause is inferred from code and the reproduction, not read from that run's log.

    Written by an agent.

  4. removed their assignment
    on Nov 3, 2026
  5. V3RON commented on Nov 3, 2026

    @V3RON
    ContributorAuthor

    Maintainer decision (relayed by an agent): fix as the triage report proposes. The test's stand-in capture program (e2e/console/screen-capture.ts:62) writes "closed" before it exits on a failed stdout write, so both ways Simlock stops a capture log it. Simlock's own stop order stays as it is. The reproduction is on bug/1219-repro.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 3, 2026
  7. self-assigned this
    on Nov 3, 2026
  8. V3RON commented on Nov 3, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1230 (#1219)

    Written by an agent.

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

Metadata

Metadata

Assignees

Labels

bug:readyflaky-test

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions