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

Merged
OK
2d ago
+110-3

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.
  • @e2e-dev/core/engine exports isE2EError.

Replaces #2543 by filip131311 (his commits are kept): his fork refuses maintainer pushes, so the review fixes could not land there.

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.

How it works

  1. allOrFirstFailure() rethrows a rejected configuration error as a ConfigurationError with the same code, the device provider "<name>" could not ... prefix, and the original as cause (packages/mobile/src/provider.ts). Other rejections take the existing EngineError('ENGINE_FAILURE') path. Both prepare (acquire) and finish (release) go through this function.
  2. It recognises the error with isE2EError(reason) && reason.category === 'configuration'. A provider package with its own copy of @e2e-dev/core throws a class that fails instanceof; isE2EError checks the marker every e2e error carries. @e2e-dev/core/engine did not export it, so this PR adds the export (packages/core/src/engine/index.ts). Mobile's core peer floor is already >=0.26.0, the release the export ships in.
  3. Unit tests (packages/mobile/tests/unit/provider.test.ts) cover acquire throwing a ConfigurationError, one from another copy (marked, failing instanceof) with code MISSING_KEY, release throwing one after every lease was tried, and an infrastructure error or an unmarked look-alike staying ENGINE_FAILURE.
  4. docs/mobile.mdx says which error gives which exit code; docs/reference/engine.mdx says to test a caught error with isE2EError.

Issue

Fixes #2542

Verified

Ran it locally: yes

  • e2e run; echo $? with the CLI built from this branch (3d317b802), a mobile({ platform: 'ios', device }) config whose provider's acquire throws. The run fails while getting a device, so no device is needed. The main column is from #2543's runs at 114a497c9.
acquire throwsmainthis PR
ConfigurationError('MISSING_KEY')ENGINE_FAILURE, exit 3MISSING_KEY, exit 2
the same from a second copy of @e2e-dev/coreENGINE_FAILURE, exit 3MISSING_KEY, exit 2
InfrastructureError('QUOTA_EXCEEDED')ENGINE_FAILURE, exit 3ENGINE_FAILURE, exit 3
ErrorENGINE_FAILURE, exit 3ENGINE_FAILURE, exit 3
 ERROR  configuration error MISSING_KEY (launch)
device provider "Toy" could not lease a device: TOY_API_KEY is not set
  • The three configuration tests fail with the rethrow removed; the look-alike test fails with the category check removed.
  • pnpm check passes.

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.

Summary by CodeRabbit

  • New Features
    • Added a public helper for identifying runner errors, including errors created by another copy of the package, and inspecting their category and code.
  • Bug Fixes
    • Provider configuration errors during device acquisition or release now retain their error code and use exit code 2 instead of being reported as engine failures. Other provider errors continue to be reported as engine failures with exit code 3.
  • Documentation
    • Updated engine error and mobile provider references to explain error identification and provider failure reporting.