Skip to content

mobile: worker replacement closes a provider-leased session and drops its device claim #792

Closed

Description

@ajoslin

Problem

A DeviceProvider cannot hold its device for the whole run on a local agent-device host. A worker replacement drops the device claim in the middle of the run.

agent-device ties host-wide device claims to a session that has an app open. A provider can take the claim by opening the slot's session (e2e-<target>-<slot>) in acquire, and the worker then resumes that session. But:

  1. e2e retires a worker after every failing unit (run/scheduler.js: if (worker.sawFailure) this.retire(worker)).
  2. @e2e-dev/mobile's AgentDeviceSurface.dispose() calls client.sessions.close() on the slot session.
  3. That close releases the device claim. Until the replacement worker reopens the session, another agent-device session can take the device or install over it.

The provider can't bridge the gap. It cannot hold a second claim-holding session, because that would block the engine's own session. agent-device 0.21.18 also has no lease that is independent of a session.

Versions

[email protected], @e2e-dev/[email protected], [email protected], iOS simulator.

Ask

When a slot is bound to a provider lease, have worker disposal keep the session (and its claim) open, for example by closing the app instead of the session, and leave closing the session to finish/release. Alternatively, add a provider hook that runs around worker replacement.

Context

A per-checkout simulator provider that installs a workspace-specific Release build under the claim: https://github.com/nelearning/chat-app/pull/3012 (e2e/native/checkoutSimulator.ts).

Activity

  1. kvnloo commented on Oct 3, 2026

    @kvnloo

    I think the useful invariant here is that worker lifetime is an implementation detail; externally leased resource lifetime belongs to the slot/run that owns the lease.

    If a failing unit retires a worker, disposal should be allowed to tear down the worker client/app without releasing the provider-backed device claim. The replacement worker should resume the same slot lease, and only provider release/run finish should end ownership.

    A regression test that intentionally fails one unit, forces worker replacement, then proves (1) the replacement resumes the same lease/session and (2) a competing session cannot claim the device during the gap would pin the root cause much more strongly than a provider-specific workaround. Does that match where you want the provider/engine lifecycle boundary to live?

  2. added
    P2Improvement / follow-up
    bugSomething isn't working
    driverdriver-1 SPI and reference web driver
    on Oct 13, 2026
  3. okwasniewski commented on Oct 19, 2026

    @okwasniewski
    Member

    Fixed in #1209: when a slot holds a provider lease, worker replacement now keeps the session and its device claim, and only release / run finish closes it. It's on main and in the nightly (npm i @e2e-dev/mobile@nightly e2e@nightly), and ships in the next stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Improvement / follow-upbugSomething isn't workingdriverdriver-1 SPI and reference web driver

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions