Skip to content

Fix the races behind five tests that fail on unrelated pull requests - #19096

Merged
dhh merged 1 commit into
quattrofrom
flaky-test-races
Nov 16, 2026
Merged

dhh merged 1 commit into
quattrofrom
flaky-test-races

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

Five tests fail on pull requests that do not touch their code, and pass when the run is repeated. Each has a cause that a busy CI VM exposes, and two of those causes are in the commands rather than the tests.

omarchy-kernel can read a matching kernel as a miss. omarchy-kernel-test.sh failed "the previous menu leader is rebuilt" on run 43650062736 (#18951) and "the kernel that led the menu is restored, though get could not name it" on 43508555148 (#18821). first_menu_kernel checked each menu entry with printf '%s\n' "${kernels[@]}" | grep -Fxq. Bash writes each of printf's lines separately, so when the entry matches an early kernel, grep can exit before the rest are written; printf then takes SIGPIPE, and pipefail turns the match into a miss. The function goes on to name a later kernel, so a failed switch can decide the old kernel already leads the menu and skip rebuilding it. The entry is now compared in Bash. Under load on a worker the test failed 7 of 200 runs on quattro and 0 of 200 with this change.

A privileged helper can refuse to run because wait lost its child. update-stay-awake-security-test.sh failed "concurrent start and stop are serialized", after wait: pid … is not a child of this shell, on 43519859663 (#18795). omarchy_security_sanitize_bash_environment read env -0 through a process substitution and then waited on its pid for env's status. Bash can reap a finished process substitution before that wait, which then fails, and the helper exits without doing anything. The environment is now read through a pipeline under lastpipe, so the loop still fills unsets in this shell, and env's status comes from PIPESTATUS. lastpipe does nothing with job control on, so the function fails closed there rather than sanitizing nothing. Called 48,000 times under load, the function failed 4 times on quattro and never with this change, and it still strips BASH_FUNC_*, BASH_ENV, PS4 and CDPATH before re-executing.

The screen recording toggle could arrive after the pending start had given up. screenrecording-concurrency-test.sh failed "a toggle during a pending start does not begin another recording" on 43735030677 (#18806) and passed on rerun. The test shortens the start's 0.2s ready poll to 0.05s, which also shortens its 75-tick ready timeout to under four seconds. A toggle that reaches the lock after that finds no start in progress and begins a recording of its own. The stub now keeps a start whose recorder never becomes ready waiting until a toggle or stop leaves its cancel request, or the start itself is gone, so the toggle always meets the pending start it is testing. Holding the toggle back four seconds reproduces the CI failure on quattro, and the test passes that way with this change.

The thumbnail check could run before the thumbnail was in place. menu-images-test.sh failed "lazy image menu retains new and changed jobs while its pool is busy" on 43507843783 (#18793) and on the translation sync's run 43557709833. The stub converter records its conversion before it exits, and generate_thumbnail moves the output to its cached name only after that, so the test could count all 42 conversions and look for a file that was a moment away. The wait now also waits for the two thumbnails it checks. Delaying the stub's exit by 0.1s fails on quattro every time and passes with this change.

The router timing read a clock that time sync steps. test/cli failed "an alias dispatch costs a fraction of loading the whole command table" on 43520043860 (#18816) and on quattro in 43762244320, where loading the whole table for help took 7ms and 40ms against its usual 400ms. test/cli runs in the first minute after the CI VM boots, which is when systemd-timesyncd makes its first synchronization: 32 seconds into a worker's boot, with systemd-resolved logging the clock change. EPOCHREALTIME follows that step, so one of the five help timings came out near zero. The timings now read /proc/uptime, which counts from boot; its 10ms resolution is fine against a fourfold margin on a few hundred milliseconds. With the clock stepped back during the run, the old timing reports help at -279ms and fails, and the new one passes.

Left alone here:

  • dropdown-test.sh, "dropdown popup fits short lists and preserves capped scrolling", is the most frequent of all (six of the last 50 failed runs, among them quattro pushes 43503794578, 43720716849 and 43754051236, and the first attempt of 43735138887 for Print usage for omarchy-notification-send --help instead of sending a notification #18819, which passed on rerun), and this does not fix it. The report from Report what the dropdown test sees when its keyboard walk stalls #18872 shows the test's own window losing activation partway through the keyboard walk (winActive false afi null), so the key presses go nowhere. On the offscreen platform a window loses activation only when another window in the process is shown or activated, or the focused one is destroyed. The test did not fail once in 136 runs on workers: under load, in the desktop session's environment with fcitx5's input context loaded, and while fcitx5 reloaded, restarted and switched input methods. Its cause is not established, so this change does not guess at one.
  • i18n-startup-test.sh failed on unrelated pull requests until Watch translation files before rereading them, so no change is lost #18734 fixed the race behind it, and has not failed since.
  • lock-appear-budget-test.sh missed its 2720ms budget once (43702321635, Drop the N1x rescue boot entry #18913, passed on rerun). That is a performance budget, and how much room it has is a decision for whoever set it.
  • shell-idle-spawn-test.sh (43766749323) and manifest-entrypoints-test.sh (43754104425) each failed once when the quickshell under test was killed with SIGKILL. Neither run's kernel log records an OOM kill, and neither has recurred.

Reviewed by Codex Medium, which found nothing to change and agreed with each cause; it reads from the machine this was written on, so its agreement is not an independent check.

omarchy-kernel compared menu entries through printf | grep -q under pipefail, so an early match could SIGPIPE printf and read as a miss. The privileged environment sanitizer waited on a process substitution Bash could already have reaped; it now reads a lastpipe pipeline and takes env's status from PIPESTATUS, failing closed with job control on.

The screen recording test let a pending start's shortened ready timeout run out before the toggle arrived, the thumbnail test checked for files before generate_thumbnail moved them into place, and the router timing read a wall clock that time sync steps right after the CI VM boots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes two command races and makes three test waits more reliable.

  • Kernel switching finds the first installed kernel in the menu.
  • Privileged helpers finish sanitizing their environment before restarting.
  • The CLI timing check ignores wall-clock jumps.
  • The image test waits until changed thumbnails reach the cache.
  • A never-ready recording stays pending until a competing action cancels it.

No actionable issues found. Tests were not run during this review.

Author omarchybot explicitly leaves the dropdown focus failure unresolved because its cause is unknown, leaves the lock timing budget to its owner, and does not change the isolated SIGKILL failures. The description also identifies the startup translation race as already fixed.

Reviews (1) · Last reviewed commit: "Fix the races behind five tests that fai..." · Reviewed by Greptile

@dhh
dhh merged commit 0746020 into quattro Nov 16, 2026
3 checks passed
@dhh
dhh deleted the flaky-test-races branch November 16, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants