Skip to content

test(acp): keep the delayed fake agent alive until its exit delay is up - #1648

Merged
okwasniewski merged 2 commits into
mainfrom
kacper/eng-1185-acp-flaky-executor-test-the-fake-agent-is
Nov 9, 2026
Merged

okwasniewski merged 2 commits into
mainfrom
kacper/eng-1185-acp-flaky-executor-test-the-fake-agent-is

Conversation

@kacperkapusciak

@kacperkapusciak kacperkapusciak commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

The acp test "retries the session directory removal after the agent exits when the first try fails" has failed 12 Linux CI jobs since #1626 (Node 22, 22.22.3, and 24): kill ESRCH at tests/executor.test.ts:522, because the fake agent, which should take 1.5 s to stop after SIGTERM, was gone within 500 ms. It blocks unrelated PRs such as #1647.

  • Teardown (packages/acp/src/session.ts) closes the agent's stdin and stdout pipe right before the SIGTERM. A process whose only other hold is a signal listener can exit on stdin's EOF before the signal handler runs, and a late write can hit EPIPE.
  • The fixture's delayed agent (ACP_EXIT_DELAY_MS) now holds the event loop until its delay is up. Once it is stopping, it logs a stdout error, an uncaught error, or a rejection instead of dying on it; before that, an error still ends it at once with code 1, so a real failure fails the test fast.
  • The delay starts at SIGTERM or stdin's end, whichever comes first, so an agent whose test worker died without a teardown still exits.
  • Both tests that use the delay print the agent's last log lines when it is gone early, so a future failure says why.
  • Test code only; no changeset.

Verified

Ran it locally: yes

  • The failure never reproduced: 6 runs on macOS and 37 in Linux containers (node:22.22.3, node:24, non-root, 1 and 2 CPUs), so the CI logs above are the evidence for the race.
  • With the change: pnpm --filter @e2e-dev/acp executor tests pass on macOS, and the full acp suite passed 15 times in a node:22.22.3 container as a non-root user (the test skips as root).
  • CI on this PR: the test jobs on all five Node versions passed, 22.22.3 included, where this test failed most. One check run hit an unrelated web-engine timeout (locator-frame.e2e.ts) and passed on rerun.
  • A fresh-context review found the orphan case (a held agent whose worker died would never exit); fixed by also starting the delay at stdin's end.

Tracked in ENG-1185.

The session-removal tests need an agent that takes 1.5 s to stop after SIGTERM. Teardown closes stdin and stdout around the signal, and on Linux CI the agent was sometimes gone within 500 ms. The fixture now holds the delayed agent until the delay is up, starts the delay at SIGTERM or stdin's end, logs errors instead of dying, and the tests print the agent's log when it is gone early.
@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, or the lockfile label Nov 9, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

View guided diff | Turn on auto-fix | Re-trigger cubic

@okwasniewski
okwasniewski merged commit 2ae3b18 into main Nov 9, 2026
36 of 38 checks passed
@okwasniewski
okwasniewski deleted the kacper/eng-1185-acp-flaky-executor-test-the-fake-agent-is branch November 9, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review size:M Up to 99 changed lines, not counting tests, fixtures, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants