Skip to content

test(reaper): wait for the stub to run its script before reaping - #1781

Merged
schubydoo merged 1 commit into
mainfrom
fix/stub-reaper-test-exec-race
Nov 2, 2026
Merged

schubydoo merged 1 commit into
mainfrom
fix/stub-reaper-test-exec-race

Conversation

@schubydoo

Copy link
Copy Markdown
Owner

What

test_reaper_kills_an_abandoned_stub flaked on the musl CI leg on 2026-10-31 (job 124507758854) with AssertionError: assert 22744 in [21406, 21463, 21627]. The reaper did not list the stub that the test had just spawned. The re-run passed.

The cause is a race in the test, not a reaper bug. Popen returns after the first exec, which is /usr/bin/env from the stub's shebang. env then execs python3, and while that exec is in flight, /proc/<pid>/cmdline reads empty. reap_fixture_stub_strays selects stubs by their argv, so a reap in that window skips the stub. Locally, 67 of 300 reads right after Popen returned an empty argv.

_spawn_stub now waits, up to 30 s, for <debug-file>.argv.json. run_bridge writes that file before anything else, which proves that the exec chain is done. If the stub exits or the time runs out, the helper kills it and fails loudly. With the wait, 300 of 300 reads saw the stub, and the test passed 40 of 40 local runs. Only tests/test_stub_reaper.py changes.

Checklist

  • PR title follows Conventional Commits.
  • no-changelog label applied (tests only).
  • Tests: this PR is the test fix.
  • Docs: no user-facing change.
  • just check passes locally (7641 passed).

🤖 Generated with Claude Code

test_reaper_kills_an_abandoned_stub failed once on the musl CI leg:
the reaper did not list the stub it had just spawned. Popen returns
after the first exec (/usr/bin/env from the shebang). env then execs
python3, and while that exec is in flight /proc/<pid>/cmdline reads
empty, so the argv-based reaper skips the stub. Locally, 67 of 300
reads right after Popen were empty.

_spawn_stub now waits for <debug-file>.argv.json, the stub's first
write, which proves the exec chain is done. With that wait, 300 of 300
reads saw the stub, and the test passed 40 of 40 runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schubydoo schubydoo added the no-changelog Skip the changeset/changelog requirement (CI / refactor / tests / docs) label Nov 2, 2026
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

The PR makes _spawn_stub wait until the fixture reaches its Python code before testing the reaper.

  • The reaper test waits until its stub has started before checking for it.

Reviews (1) · Last reviewed commit: "test(reaper): wait for the stub to run i..." · Reviewed by Greptile

@schubydoo
schubydoo merged commit cd93534 into main Nov 2, 2026
27 of 34 checks passed
@schubydoo
schubydoo deleted the fix/stub-reaper-test-exec-race branch November 2, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Skip the changeset/changelog requirement (CI / refactor / tests / docs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant