Remove duplicate Playwright helper initialization (drop constructor setTimeout) #5206
  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.
  
    
  
    
Playwright Helper: Remove duplicate async initialization causing race conditions
Summary
This PR removes an unnecessary
setTimeout(... _init())call from thePlaywrighthelper constructor that caused_init()to run twice in parallel during framework bootstrap. Initialization is already performed by the CodeceptJS container (container.createHelpers -> helper._init()), so the deferred constructor call was redundant and risky.Background
After merging PR #5089 (custom locator strategies + selector engine registration improvements), the constructor still contained (or reintroduced) an asynchronous fire‑and‑forget initialization pattern:
At runtime this led to two near-simultaneous executions:
global.createHelpers -> Playwright._initsetTimeoutResult: duplicate selector engine registration attempts and potential race conditions (especially if future logic adds non-idempotent side effects).
Problem Details
Stack traces showed two
_initexecutions for a singlecodecept init/ test catalog discovery phase. Although selector engine registration was wrapped intry/catch, this produced noisy logs and increased risk of subtle state bugs (e.g. shared sets likeregisteredCustomLocatorStrategies).Changes
setTimeoutcall from thePlaywrighthelper constructor._init()lifecycle._startBrowser()already awaits_init()explicitly.)Rationale
What This Does NOT Change
Reproduction Before Fix
_initstack traces and selector registration attempts.After Fix
Only one
_initcall—triggered by the container—appears in traces.Testing & Safety
_initinvocation during bootstrap.Potential Follow-Up (Optional)
If future contributions add asynchronous prep stages that must be serialized:
_initialized/_initPromiseguards (idempotence) inside_init().Migration
No action required for end users or plugin authors.
Risk Assessment
Low. The removed code path was redundant; the retained path is the canonical lifecycle hook.
Changelog Entry
Playwright Helper: Remove redundant deferred
_init()invocation to prevent duplicate initialization and potential race conditions.Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)