fix(web): re-resolve a locator that turns ambiguous before its action runs
Merged
OK
2mo ago+70+70+01234567890123456789-13-13-01234567890123456789
A tap whose locator gained a second match between locate and perform failed with a raw Playwright ENGINE_FAILURE (infrastructure) instead of LOCATOR_AMBIGUOUS.
- A single-match locate keeps Playwright's strict locator for the action (
packages/web/src/surface.ts:756), so a duplicate that appears in between makes Playwright throwstrict mode violation. classifyActionErrormapped that to non-retryableENGINE_FAILURE. It is now retryableNODE_STALE, like a detached element (packages/web/src/actions.ts:247).- The runner's existing stale retry in
performUntil(packages/e2e/src/locator/engine.ts:450) locates again: still two matches isLOCATOR_AMBIGUOUS, a duplicate that went away lets the action run on the one match. The action never runs on either element of a pair. - A violation whose call log shows input already went out (a
dragToresolves its drop target after the press) isACTION_MAY_HAVE_COMMITTED, never retried, same split the timeout path uses (POST_DISPATCH_PATTERN). POST_DISPATCH_PATTERNnow matches only whole-call log lines, so a locator or element text quotingperforming click actioncannot pass as a dispatch (affected the timeout path too).- Real-world trigger: a screen transition that briefly renders the old and new page together.
Verified
Ran it locally: yes
- testbed, built CLI, a page whose duplicate
Gobutton appears and disappears every 3 ms, 300screen.getByRole('button', 'Go').tap()calls, result codes counted:
| main | this branch |
|---|---|
ENGINE_FAILURE: locator.click: Error: strict mode violation ... x4LOCATOR_AMBIGUOUS x251ok x45 | ENGINE_FAILURE x0LOCATOR_AMBIGUOUS x265ok x35 |
- New integration tests in
lifecycle.test.ts: locate one button, add a twin, tap (fails on main withENGINE_FAILURE, hereNODE_STALEand no click); a drop target that gains a twin on mousedown (hereACTION_MAY_HAVE_COMMITTED, exactly one mousedown).