Skip to content

Commit 112ce88

Browse files
committed
fix(Playwright): Guard _init() to prevent duplicate selector registration
- Only call _init() once per process using defaultSelectorEnginesInitialized flag - Prevents duplicate selector registration errors in worker processes - Add error handling for newContext when selectors already registered Note: Worker processes still have initialization issues (ES Module loader errors) that are unrelated to selector registration. The BROWSER_RESTART=session with workers shows selector already registered errors which need further investigation.
1 parent 42a975b commit 112ce88

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/helper/Playwright.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,10 @@ class Playwright extends Helper {
11801180

11811181
async _startBrowser() {
11821182
// Ensure custom locator strategies are registered before browser launch
1183-
await this._init()
1183+
// Only init once globally to avoid selector re-registration in workers
1184+
if (!defaultSelectorEnginesInitialized) {
1185+
await this._init()
1186+
}
11841187

11851188
if (this.isElectron) {
11861189
this.browser = await playwright._electron.launch(this.playwrightOptions)

0 commit comments

Comments
 (0)