fix(mobile): keep a provider's configuration error as INVALID_CONFIG

Closed
FI
2d ago
+63-2

What

  • A device provider whose acquire or release throws a ConfigurationError now fails the run with that error's code (for example INVALID_CONFIG, exit code 2) instead of ENGINE_FAILURE (exit code 3). The message still names the provider. Any other error is still ENGINE_FAILURE.

Why

  • allOrFirstFailure() wrapped every provider rejection as ENGINE_FAILURE, so a provider that reports a missing API key or an unknown device exited 3, and CI that retries infrastructure failures retried a run that could not pass. This keeps the provider's configuration error as one.

How it works

  1. allOrFirstFailure() rethrows a rejected ConfigurationError as a ConfigurationError with the same code, the device provider "<name>" could not ... prefix, and the original as cause (packages/mobile/src/provider.ts:237). Other rejections take the existing EngineError('ENGINE_FAILURE') path on the next line. Both prepare (acquire, line 273) and finish (release, line 317) go through this function.
  2. isConfigurationError() (packages/mobile/src/provider.ts:223) also matches a ConfigurationError from a provider's own copy of @e2e-dev/core, which fails instanceof, by its category: 'configuration' and string code. Engine packages import only @e2e-dev/core/engine, which does not export isE2EError.
  3. Unit tests drive prepare with a provider whose acquire throws ConfigurationError('INVALID_CONFIG', ...) (packages/mobile/tests/unit/provider.test.ts:446), and one that throws such an error from another copy with code MISSING_KEY (line 463). They check the class, code, and message.
  4. docs/mobile.mdx:696 says which error gives which exit code.

Issue

Fixes #2542

Verified

Ran it locally: yes

  • I ran e2e run; echo $? against packages built from main (114a497c9) and from this branch (df4e0db28), with four configs:

    • the issue's config, mobile({ platform: 'ios', device: limrun() }) with LIMRUN_API_KEY unset;
    • the same config with @e2e-dev/limrun loading its own copy of e2e and @e2e-dev/core, so its ConfigurationError fails instanceof;
    • a minimal provider whose acquire throws ConfigurationError('INVALID_CONFIG', …);
    • the same provider throwing a plain Error('service unreachable').

    Each run fails while getting a device, so no device or account is needed.

mainthis PR
limrun(), no LIMRUN_API_KEYENGINE_FAILURE, exit 3INVALID_CONFIG, exit 2
limrun() on a second copy of @e2e-dev/coreENGINE_FAILURE, exit 3INVALID_CONFIG, exit 2
acquire throws ConfigurationErrorENGINE_FAILURE, exit 3INVALID_CONFIG, exit 2
acquire throws ErrorENGINE_FAILURE, exit 3ENGINE_FAILURE, exit 3

main, limrun():

 ERROR  infrastructure error ENGINE_FAILURE (launch)
device provider "Limrun" could not lease a device: @e2e-dev/limrun requires LIMRUN_API_KEY in the run environment while preparing engine mobile for target "ios"

this PR, limrun():

 ERROR  configuration error INVALID_CONFIG (launch)
device provider "Limrun" could not lease a device: @e2e-dev/limrun requires LIMRUN_API_KEY in the run environment

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Configuration errors raised while acquiring or releasing a device now fail the run with the provider’s error code, such as INVALID_CONFIG (exit code 2), instead of ENGINE_FAILURE (exit code 3). The error message continues to identify the provider.
  • Documentation
    • Clarified that if any worker slot cannot be leased, the run ends before tests start and previously acquired leases are released. Documented how configuration errors and other provider errors affect run status and exit codes.