Found in review of #43: tests/view-mail.sh fails at random (view mail left gc events --follow running) #69

Merged
city-root merged 1 commit from worker/gascitypacks-r82 into main 2026-11-12 16:56:06 +00:00
Contributor

tests/view-mail.sh failed at random with "view mail left gc events --follow running" (run 1663 of #43, a pull request that touches neither the test nor the command).

Cause. After the view is killed, its cleanup sends the stub's gc events --follow its signal and the view exits at once. The test looked once with kill -0 for the stream, so on a loaded runner it looked before the stream was gone.

Change. Each pid the stub recorded is waited for with the test's own stopped helper, up to five seconds, instead of being looked at once. No new shell logic: the helper exists and the loop keeps its shape. A fragment in .changelog/ notes it.

Same pattern elsewhere. None: view-beads.sh records no stream pids and already uses stopped; upgrade.sh kills its orphan and does not check it afterwards.

The SIGPIPE in gnu-tools.sh. It has a bead of its own, gascitypacks-cbz, closed by #37 (grep -q under pipefail); nothing of it is left in the file, so nothing to fix here.

Checked. tests/view-mail.sh five times in a row and tests/view-beads.sh: ok; shellcheck tests/view-mail.sh: clean; the changelog v2 checker from the repository root: pass. Not reproduced: the race itself, which depends on load.

Bead: gascitypacks-r82

`tests/view-mail.sh` failed at random with "view mail left gc events --follow running" (run 1663 of #43, a pull request that touches neither the test nor the command). **Cause.** After the view is killed, its cleanup sends the stub's `gc events --follow` its signal and the view exits at once. The test looked once with `kill -0` for the stream, so on a loaded runner it looked before the stream was gone. **Change.** Each pid the stub recorded is waited for with the test's own `stopped` helper, up to five seconds, instead of being looked at once. No new shell logic: the helper exists and the loop keeps its shape. A fragment in `.changelog/` notes it. **Same pattern elsewhere.** None: `view-beads.sh` records no stream pids and already uses `stopped`; `upgrade.sh` kills its orphan and does not check it afterwards. **The SIGPIPE in `gnu-tools.sh`.** It has a bead of its own, `gascitypacks-cbz`, closed by #37 (`grep -q` under pipefail); nothing of it is left in the file, so nothing to fix here. **Checked.** `tests/view-mail.sh` five times in a row and `tests/view-beads.sh`: ok; `shellcheck tests/view-mail.sh`: clean; the changelog v2 checker from the repository root: pass. Not reproduced: the race itself, which depends on load. Bead: gascitypacks-r82
fix: tests/view-mail.sh waits for the followed stream to be gone (gascitypacks-r82)
All checks were successful
test / changelog (pull_request) Successful in 5s
test / lint (pull_request) Successful in 21s
test / scripts (pull_request) Successful in 33s
ef57db5215
The test killed the view and then looked once, with kill -0, for the stub's
gc events --follow. The view's cleanup sends that process its signal and the
view exits at once, so the stream is gone a moment after the view, not with it:
on a loaded runner the single look came first and the test failed with
"view mail left gc events --follow running" (run 1663 of gascitypacks#43,
which touched neither the test nor the command).

Each pid the stub recorded is now waited for with the test's own stopped
helper, up to five seconds, as the view itself already is. No new logic: the
helper exists and the loop keeps its shape. The pattern is not in the other
tests: view-beads.sh records no stream pids and already uses stopped, and
upgrade.sh kills its orphan without checking it afterwards.

The SIGPIPE in tests/gnu-tools.sh has a bead of its own, gascitypacks-cbz,
fixed by #37 (a grep -q under pipefail); nothing of it is left there.

Validation: tests/view-mail.sh run five times, ok each time; the changelog v2
checker passes from the repository root.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review left a comment

Review of ef57db5215 for gascitypacks-r82. Checks of the head: success.

Verdict

pass

Findings

None that block, and no minor ones.

Verified

  • The requirement (gascitypacks-r82: wait for the child with a bound instead of looking once, say so, look for the same pattern in the other view tests, the SIGPIPE in gnu-tools.sh if it has no bead, a changelog fragment, no new shell logic) is met:
    • tests/view-mail.sh:263: each recorded stream pid now goes through the test's own stopped helper (5 one-second tries, tests/view-mail.sh:51-58) in place of a single kill -0. The comment at :256-258 says why. Nothing else in the loop changed, so no new shell logic was added.
    • The cause matches the code: the view's cleanup (roles/commands/view/mail/run.sh:54-58) sends the signal to gcpid and exits without waiting, and the stub's stream is exec sleep 600, which is orphaned when the view exits. The old test checked once, straight after the view stopped. The old kill -0 passed on most CI runs, so the runner reaps orphans and waiting for them is enough.
    • Same pattern elsewhere: kill -0 appears in tests/ only in view-mail.sh and view-beads.sh. view-beads.sh uses it only inside its own stopped helper and records no stream pids, as the description says.
    • SIGPIPE in gnu-tools.sh: the description names its own bead (gascitypacks-cbz, closed by #37), so nothing is owed here.
    • .changelog/view-mail-test-waits-for-stream.md is a ### Fixed fragment, and the PR has a description.
  • I merged the head into the current origin/main (4a39722, Release 0.7.0) in my own clone: clean, no conflict. The forge says mergeable.
  • On the merged tree, with the city's variables removed (env -i, 0 such variables):
    • bash tests/view-mail.sh 3 times in a row: ok each time.
    • bash tests/view-beads.sh: ok.
    • shellcheck tests/view-mail.sh: clean.
    • The changelog checker, built from sarak.sh/mikluko/changelog tag v2 (087d7e8, v2.1.0), run as actions/validate runs it with -base=main: valid=true, exit 0.
  • Not run locally: the Go vet/test, the lint job and the other script tests, since the diff touches no Go and no other script. CI ran them on this head: success.
  • Not reproduced: the race itself, which needs a loaded runner. The fix waits up to five seconds where the old test looked once.
Review of ef57db5215e7755e636171128fd6dd7b564d0406 for gascitypacks-r82. Checks of the head: success. ### Verdict pass ### Findings None that block, and no minor ones. ### Verified - The requirement (gascitypacks-r82: wait for the child with a bound instead of looking once, say so, look for the same pattern in the other view tests, the SIGPIPE in gnu-tools.sh if it has no bead, a changelog fragment, no new shell logic) is met: - `tests/view-mail.sh:263`: each recorded stream pid now goes through the test's own `stopped` helper (5 one-second tries, `tests/view-mail.sh:51-58`) in place of a single `kill -0`. The comment at `:256-258` says why. Nothing else in the loop changed, so no new shell logic was added. - The cause matches the code: the view's `cleanup` (`roles/commands/view/mail/run.sh:54-58`) sends the signal to `gcpid` and exits without waiting, and the stub's stream is `exec sleep 600`, which is orphaned when the view exits. The old test checked once, straight after the view stopped. The old `kill -0` passed on most CI runs, so the runner reaps orphans and waiting for them is enough. - Same pattern elsewhere: `kill -0` appears in `tests/` only in view-mail.sh and view-beads.sh. view-beads.sh uses it only inside its own `stopped` helper and records no stream pids, as the description says. - SIGPIPE in gnu-tools.sh: the description names its own bead (gascitypacks-cbz, closed by #37), so nothing is owed here. - `.changelog/view-mail-test-waits-for-stream.md` is a `### Fixed` fragment, and the PR has a description. - I merged the head into the current `origin/main` (4a39722, Release 0.7.0) in my own clone: clean, no conflict. The forge says `mergeable`. - On the merged tree, with the city's variables removed (`env -i`, 0 such variables): - `bash tests/view-mail.sh` 3 times in a row: ok each time. - `bash tests/view-beads.sh`: ok. - `shellcheck tests/view-mail.sh`: clean. - The changelog checker, built from sarak.sh/mikluko/changelog tag v2 (087d7e8, v2.1.0), run as `actions/validate` runs it with `-base=main`: valid=true, exit 0. - Not run locally: the Go vet/test, the lint job and the other script tests, since the diff touches no Go and no other script. CI ran them on this head: success. - Not reproduced: the race itself, which needs a loaded runner. The fix waits up to five seconds where the old test looked once.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/gascitypacks!69
No description provided.