Skip to content

test: stabilize proxy tests#1762

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/test/wait-for-proxy
Open

test: stabilize proxy tests#1762
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/test/wait-for-proxy

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 27, 2026

Proxy-related tests have been failing quite often lately

Replace the hardcoded 0.5s sleep with a wait loop that gives mitmdump up to 10s to get a response from the mock server. This should help in busy CI environments where runners may be under load and processes can be delayed.

@jpnurmi jpnurmi force-pushed the jpnurmi/test/wait-for-proxy branch from 4e5b9f3 to 95b285f Compare May 27, 2026 16:05
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 95b285f. Configure here.

Comment thread tests/proxy.py
stdout_bytes, _ = proxy_process.communicate()
stdout = stdout_bytes.decode("utf-8", errors="replace")
stdout_bytes, _ = proxy_process.communicate(timeout=timeout)
stdout = "".join(stdout) + stdout_bytes.decode("utf-8", errors="replace")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reader thread and communicate() race on same stdout pipe

Medium Severity

The reader thread reads from proxy_process.stdout via readline(), and then proxy_process.communicate() is called on the same pipe. communicate() internally calls self.stdout.read() followed by self.stdout.close(). If communicate() acquires the BufferedReader lock before the reader thread finishes its loop, it will close the file object, causing the thread's next readline() to raise ValueError. This also means the two readers compete for pipe data — the thread never gets joined, so there's no guarantee it's finished before "".join(stdout) on line 165 is evaluated. The fix would be to avoid calling communicate() and instead use proxy_process.wait() + reader.join() to collect output solely through the reader thread.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 95b285f. Configure here.

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