Skip to content

test(web-fetch): remove timing races from the native CDP port test - #225

Merged
lanyue-llk merged 1 commit into
mainfrom
test/native-cdp-port-race
Nov 4, 2026
Merged

lanyue-llk merged 1 commit into
mainfrom
test/native-cdp-port-race

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #216

Summary

test_port_check_ignores_the_log_of_an_earlier_attempt failed at random in CI with DID NOT RAISE RuntimeError, on PRs that do not touch this code. Its stand-in server called listen() and then exited, so the fake handshake could succeed in that gap.

The rest of the file had the same kind of dependence on timing, so this makes all of it deterministic:

  • A stand-in that must be gone before any handshake never listens.
  • A stand-in that must outlive a step blocks on stdin until the harness releases it, instead of relying on short sleeps such as time.sleep(.2).

Test-only. No production code changes.

Test plan

Run locally on macOS with Python 3.11 from the shared locked environment.

  • tests/test_native_cdp_port.py 12 times in a row with four busy CPU processes running: 15 passed each time, 3 to 8 seconds per run.
  • tests/test_native_cdp_port.py and tests/test_explicit_utf8_io.py: 77 passed.
  • Lint gate: ruff check --config 'include=["*.py"]' --select F,TID252 . and ruff check pass. Pointing ruff directly at this file reports one E501 on line 91, an existing line this PR does not change; the same error appears on main.
  • Mutation check of headless.py, each applied alone and reverted, and each made the file fail: reading the whole log instead of this attempt's (1 failed), removing the exit check after the caller finishes (2 failed), and keeping a browser whose server already exited (1 failed).
  • CI on Linux.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ℹ️ Review skipped · 9bd5880

No reviewable content was selected for this run.

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
@lanyue-llk
lanyue-llk force-pushed the test/native-cdp-port-race branch from 9bd5880 to 3dd29de Compare November 4, 2026 04:50

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ℹ️ Review skipped · 3dd29de

No reviewable content was selected for this run.

@lanyue-llk
lanyue-llk merged commit f655913 into main Nov 4, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the test/native-cdp-port-race branch November 4, 2026 04:56
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.

Remove the race in the native CDP port test

1 participant