fix(provider-webdriver): allocate one WebDriver session per lease

Merged
TH
11h ago
+1559-98

Summary

Concurrent allocations of one lease could rent two billed WebDriver sessions, and teardown during creation could orphan a session. The manager now publishes one lease entry synchronously, shares its creation and disposal, refuses allocations during teardown, and reports cleanup outcomes with session identities.

Provider callback budgets cover prepared-session cleanup on disposal and failed creation, plus teardown listArtifacts. prepareSession remains unbounded; release and shutdown wait for preparation. Release awaits artifacts even when it joins a shutdown take; freeing the lease slot and shutdown() await disposal only.

Node option: createCloudWebDriverRuntime({ ...options, providerCallbackTimeoutMs: 5000 }).

Four files in packages/provider-webdriver; no scope expansion. SM-3; related #4102.

Validation

Tested head e094faebb3a6899a89b95410647fa9331ad33fa7; base f7879cf2d266ee1dd476d0342b2819bdeceb647b.

pnpm format and pnpm check:affected --run --head e094faebb3a6899a89b95410647fa9331ad33fa7 passed (exactCommit: true); receipt .tmp/validation/run-NzjuKc/receipt.json.

Both real BrowserStack races passed at 86216483fb: release and shutdown during unanswered POST /session, followed by same-lease allocation. Each created/deleted the same session ID, left zero owned sessions live, and returned the expected typed refusals. Full logs and validation receipt: review response.

This follow-up changes comments only; runtime behavior is unchanged from the live-tested head. Existing fail-first results remain in earlier review responses. GitHub owns full coverage, provider integration, and device lanes. Limitation: no-app Android sessions; no app-upload path was exercised. Independent review remains with the coordinator.