Repository navigation
Conversation
Cancellation or errors after the context refcount bump in get_page() used to leak the acquire, which permanently filled the recycle pending queue and deadlocked the Docker server under wall_clock_s cancels (unclecode#2419). - Undo unreturned acquires (refcount + page) on BaseException - Shield new_page so a late Playwright page is closed after cancel - Make recycle bump non-blocking: clear drained pending entries, else defer
Hugo-DDT
force-pushed
the
fix/2419-get-page-refcount-cancel
branch
from
October 23, 2026 09:04
9556406 to
73d2837
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2419.
BrowserManager.get_page()incremented a context refcount and then awaitednew_page(), stealth setup, and browser recycle. OnlyExceptionfromnew_page()undid the acquire.asyncio.CancelledError(raised when the Docker server hitswall_clock_s) and failures afternew_page()leaked the refcount. Leaked entries never drained from_pending_cleanup, filled the 3-slot cap, and left laterget_page()calls waiting inside recycle until they were cancelled too — a permanent Docker deadlock.Changes
get_page()never hands the page back, release the refcount and close any page we created (covers cancel and otherBaseExceptions).new_page()— shield the Playwright call and close a page that finishes after the caller was cancelled.get_page().Test plan
pytest tests/browser/test_get_page_refcount_cancel_2419.py(6 new tests: cancel duringnew_page, stealth failure, cancel during bump, defer when drain full, clear drained then bump, successful handoff keeps refcount)TestSignatureShrink+TestLRUEvictionstill pass