fix(browsers): do not close a browser as inactive while a page opening is in flight - #2156
Open
vdusek wants to merge 1 commit into
Open
fix(browsers): do not close a browser as inactive while a page opening is in flight#2156vdusek wants to merge 1 commit into
vdusek wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2156 +/- ##
==========================================
+ Coverage 93.51% 93.61% +0.10%
==========================================
Files 181 181
Lines 12653 12664 +11
==========================================
+ Hits 11832 11855 +23
+ Misses 821 809 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vdusek
marked this pull request as ready for review
August 14, 2026 10:05
Pijukatel
approved these changes
Aug 14, 2026
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.
The
windows-latest / 3.10unit-test job failed withTargetClosedError: BrowserContext.new_page: Target page, context or browser has been closedintest_new_page_with_each_plugin. It is not a test flake: theBrowserPoolinactive-browser reapers judge a browser only by its finished pages (idle_timeruns from controller construction andpagesis populated only oncenew_pagereturns), so on a slow runner they gracefully close a freshly launched browser whose firstnew_page()is still creating its context. Any user on a loaded machine can hit the same error (related: #1660).The fix exposes the already-tracked in-flight openings as
BrowserController.is_opening_pagesand guards both reapers with it, so such a browser is neither marked inactive nor closed. A new regression test reproduces the race deterministically by gating the firstcontext.new_page()call and running one reaper cycle while the opening is pending — it fails with the exact CI error before the fix and passes after.✍️ Drafted by Claude Code