Blocking synchronous I/O (time.sleep, urllib) inside async event loop degrades performance
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- backend, performance
Research direction
Start in local_browser.py at _is_local_cdp_available(), _local_cdp_page_targets(), _ensure_local_cdp_page_target(), and _ensure_local_cdp_browser(); inspect how these helpers are called and review the existing httpx dependency in pyproject.toml. Replace blocking HTTP and sleep operations with async equivalents, then verify CDP startup does not block or prevent cancellation of the polling loop.
Written by the indexing model from the issue text.
Description
Description
In \local_browser.py, several synchronous I/O operations run inside async methods, blocking the asyncio event loop:
- _is_local_cdp_available()\ (line 58) and _local_cdp_page_targets()\ (line 73) use \urllib.request\ synchronously
- _ensure_local_cdp_browser()\ (line 262) uses \ ime.sleep(0.2)\ in a polling loop, blocking the loop for up to 10 seconds
- _ensure_local_cdp_page_target()\ (line 93) uses synchronous urllib
\httpx\ is already listed as a dependency in \pyproject.toml\ (line 11) but isn't used anywhere.
Impact
- The event loop is blocked during CDP browser startup for up to 10 seconds
- \ ime.sleep()\ is not interruptible (unlike \syncio.sleep())
- Concurrent operations on the same event loop cannot make progress
- The polling loop cannot be cancelled mid-wait
Suggested Fix
Replace the synchronous helpers with async versions using \httpx.AsyncClient, convert _ensure_local_cdp_browser\ to async, and use \syncio.sleep()\ instead of \ ime.sleep().
The fix is straightforward since httpx is already a project dependency.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 385
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/Webwright
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoft/Webwright
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100