Skip to content

tests: fix headless Chrome cold-start flake and surface startup retry notes - #227

Merged
sreejithraman merged 2 commits into
mainfrom
fix/chrome-startup-flake
Nov 22, 2026
Merged

sreejithraman merged 2 commits into
mainfrom
fix/chrome-startup-flake

Conversation

@sreejithraman

Copy link
Copy Markdown
Owner

Summary

Fixes the recurring TimeoutError: Browser.getVersion headless Chrome cold-start flake in CI (skills/coordinator/scripts/test_command_center.py and skills/coordinator/scripts/test_sites_refresh.py, observed in runs 44221521208, 44834084949, 44877259152, and 44986044435).

Changes

  • Serialize Chrome cold-start handshakes across parallel check.py workers (skills/coordinator/scripts/test_command_center.py): startup_lock() uses an fcntl.flock lock in _SREESTACK_TEST_CACHE/chrome-startup.lock scoped per startup attempt so test_command_center.py and test_sites_refresh.py don't cold-start two headless Chrome instances simultaneously, while running their actual test suites in parallel.
  • Retry transient startup stalls fast within CI's 75s budget: start_chrome() uses STARTUP_TIMEOUTS = (10, 15), retries only transient (TimeoutError, ConnectionError) handshake failures, immediately force-kills (SIGKILL via close(force=True)) failed startup candidates instead of waiting 10s on SIGTERM, and cleans up temporary profiles on every error path.
  • Isolate stdio & improve failure/retry visibility:
    • Pass stdin=subprocess.DEVNULL and --enable-logging=stderr --log-level=2 to headless Chrome; enrich BrokenPipeError and still-alive timeout diagnostics with PID/exit code and Chrome stderr tail.
    • Record startup retry/recovery notes in _SREESTACK_TEST_CACHE/notes.log and surface non-empty notes.log on scripts/check.py stderr even when tests pass, so retries never hide silently on green runs.
    • Guard setUpModule() HTTP server setup and isolate tearDownModule() steps via contextlib.ExitStack, making Chrome.close() idempotent across descriptor errors.
  • Tests:
    • Added skills/coordinator/scripts/test_chrome_startup.py (7 unit tests covering retries, force-kill, non-transient errors, cross-process flock serialization, stdin/logging/diagnostics/BrokenPipeError, idempotent close(), and teardown/setup error isolation).
    • Added notes.log pass-through assertion to scripts/test_check.py.

Verification

  • python3 scripts/check.py skills/coordinator/scripts/test_chrome_startup.py: 7/7 passed (0.64s)
  • python3 scripts/check.py: 564 tests across 26 files passed in 32.60s (Checked 63 skills, local Markdown paths/anchors, and skill link hygiene.)
  • Independent 2-pass review-fix-loop (sreestack-chrome-startup-flake): Pass 1 Primary + Adversarial, Pass 2 Primary APPROVE on a4fb479f.
  • Linux ubuntu-latest runtime verification: covered by this PR's Skills and secrets CI run.

@sreejithraman
sreejithraman merged commit d019587 into main Nov 22, 2026
2 checks passed
@sreejithraman
sreejithraman deleted the fix/chrome-startup-flake branch November 22, 2026 13:55
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.

1 participant