fix(mobile): keep a provider's configuration error as INVALID_CONFIG
Merged
OK
2d ago+110+110+012345678901234567890123456789-3-3-0123456789
What
- A device provider whose
acquireorreleasethrows aConfigurationErrornow fails the run with that error's code (for exampleINVALID_CONFIG, exit code 2) instead ofENGINE_FAILURE(exit code 3). The message still names the provider. Any other error is stillENGINE_FAILURE. @e2e-dev/core/engineexportsisE2EError.
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 asENGINE_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
allOrFirstFailure()rethrows a rejected configuration error as aConfigurationErrorwith the same code, thedevice provider "<name>" could not ...prefix, and the original ascause(packages/mobile/src/provider.ts). Other rejections take the existingEngineError('ENGINE_FAILURE')path. Bothprepare(acquire) andfinish(release) go through this function.- It recognises the error with
isE2EError(reason) && reason.category === 'configuration'. A provider package with its own copy of@e2e-dev/corethrows a class that failsinstanceof;isE2EErrorchecks the marker every e2e error carries.@e2e-dev/core/enginedid 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. - Unit tests (
packages/mobile/tests/unit/provider.test.ts) coveracquirethrowing aConfigurationError, one from another copy (marked, failinginstanceof) with codeMISSING_KEY,releasethrowing one after every lease was tried, and an infrastructure error or an unmarked look-alike stayingENGINE_FAILURE. docs/mobile.mdxsays which error gives which exit code;docs/reference/engine.mdxsays to test a caught error withisE2EError.
Issue
Fixes #2542
Verified
Ran it locally: yes
e2e run; echo $?with the CLI built from this branch (3d317b802), amobile({ platform: 'ios', device })config whose provider'sacquirethrows. The run fails while getting a device, so no device is needed. The main column is from #2543's runs at 114a497c9.
acquire throws | main | this PR |
|---|---|---|
ConfigurationError('MISSING_KEY') | ENGINE_FAILURE, exit 3 | MISSING_KEY, exit 2 |
the same from a second copy of @e2e-dev/core | ENGINE_FAILURE, exit 3 | MISSING_KEY, exit 2 |
InfrastructureError('QUOTA_EXCEEDED') | ENGINE_FAILURE, exit 3 | ENGINE_FAILURE, exit 3 |
Error | ENGINE_FAILURE, exit 3 | ENGINE_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 checkpasses.
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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@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.