fix(provider-webdriver): never resend a mutating WebDriver request
Merged
TH
2mo ago+960+960+012345678901234567890123456789-125-125-012345678901234567890123456789
Summary
Part of #3069.
Twelve mutating WebDriver routes were sent again after a timeout or a 5xx (actions, keys, back, rotation, orientation, installApp, activateApp, terminateApp, deleteSession, and the mobile: scripts deepLink, activateApp, pressButton, setClipboard). A slow tap, type, or back could run twice. The first commit proves it on main through the real client and transport.
- Retry follows the HTTP method: GET and HEAD keep the policy's retry budget; every other method gets one attempt unless the request is marked idempotent (
mobile: getClipboard, a POST read, is the one opt-in). No per-call opt-out to forget. - The transport says what it knows, typed as
'no' | 'unknown':dispatched: "no"only when the failure proves the request never reached the driver (cause code inECONNREFUSED,ENOTFOUND,EAI_AGAIN,EHOSTUNREACH,ENETUNREACH,UND_ERR_CONNECT_TIMEOUT, throughcausechains andAggregateErrormembers); any otherTypeError, a post-body socket reset, a body-read failure, a timeout, or a 5xx is"unknown"withreason: webdriver_request_interrupted. - One classifier for "route unsupported", in the transport: a W3C error code decides when present (
unknown command/unknown method;invalid session idis not unsupported); with no code, a bare 404, 405, or 501. It setsreason: webdriver_route_unsupported; theactivateApp/terminateAppsibling fallback, orientation, and the keyboard/active-element probes all read that reason. Two--debugdiagnostics:webdriver_route_unsupported(method, path, status, W3C code) andwebdriver_route_fallback(from, to, status) after the sibling succeeds; both loaded on demand so the eager closure holds.
11 files. Web sessions only.
Validation
Tested commit e307316606. pnpm check:affected --run: all runnable checks passed.
webdriver-mutation-resend.test.ts: table over all 17 mutating routes (enumerated from the client source), one send anddispatched: "unknown"per row on a timeout; GET/sourceandmobile: getClipboardstill retried; POST 5xx one call.webdriver-transport.test.ts: real sockets, no doubles: a released port →no; a server that resets after reading the body →unknown, one request; headers then reset →unknown. Ten-row unsupported-route table through the real transport.- Live, two current drivers,
openthenclosewith--debug: AWS Device Farm iPhone Air / iOS 26.3.1 (XCUITest), and BrowserStack Google Pixel 8 / Android 14.0 on Appium v3.2.0 with UiAutomator2 driver v7.0.0 (its Appium log:POST .../appium/device/activate_app 200 98 ms,.../terminate_app 200 209 ms, one send each, no/execute/sync). Both still serve the legacy route, soopen/closeare unchanged there and the sibling fallback is dormant; it is proven through the real transport against a 404 answer and covered by the typed reason and the two diagnostics. - Behavior change to note: a bare 404 from the keyboard or active-element probe now reads as unsupported, by the one rule (before: 405/501 only).