Skip to content

Commit c75dc27

Browse files
committed
fix(ios): scope reinstall guarantees to preparation failures
1 parent d7e15e0 commit c75dc27

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎packages/command-surface/src/management/install.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const installCommandMetadata = defineFieldCommandMetadata(
3838

3939
const reinstallCommandMetadata = defineFieldCommandMetadata(
4040
'reinstall',
41-
'Replace an installed app with a binary from a local path. This preserves the app identity while installing a new build on the selected device. Local Android and iOS install steps time out after 120s; the command allows 480s including device startup and uninstall. On iOS, a build that cannot be read leaves the installed app in place; a failure during install after the uninstall can still leave the app removed.',
41+
'Replace an installed app with a binary from a local path. This preserves the app identity while installing a new build on the selected device. Local Android and iOS install steps time out after 120s; the command allows 480s including device startup and uninstall. On iOS, a corrupt .ipa that cannot be unpacked leaves the installed app in place. An invalid app bundle or another install failure after uninstall can still leave the app removed.',
4242
{
4343
app: requiredField(stringField()),
4444
appPath: requiredField(stringField('Path to app binary.')),

‎packages/platform-apple/src/deployment/runtime.test.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,14 @@ test('reinstall releases the prepared replacement when uninstall fails', async (
610610
});
611611

612612
test('clears a concurrently repopulated fuzzy resolution after a preparation-failed Apple reinstall', async () => {
613-
const cachedResolutions = new Map([['Maps', 'com.example.stale-before-uninstall']]);
613+
const cachedResolutions = new Map([['Maps', 'com.example.stale-before-resolution']]);
614614
let nextResolution = 'com.example.current';
615615
const resolveFuzzyTarget = vi.fn(async (target: string) => {
616616
const resolved = cachedResolutions.get(target) ?? nextResolution;
617617
cachedResolutions.set(target, resolved);
618618
return resolved;
619619
});
620-
const invalidateDuringUninstall = async <Result>(operation: () => Promise<Result>) => {
620+
const invalidateDuringResolution = async <Result>(operation: () => Promise<Result>) => {
621621
cachedResolutions.clear();
622622
try {
623623
return await operation();
@@ -627,15 +627,15 @@ test('clears a concurrently repopulated fuzzy resolution after a preparation-fai
627627
};
628628
const resolveAppBundleId = vi.fn(
629629
async (_device: DeviceInfo, app: string) =>
630-
await invalidateDuringUninstall(async () => {
630+
await invalidateDuringResolution(async () => {
631631
const bundleId = await resolveFuzzyTarget(app);
632632
expect(bundleId).toBe('com.example.current');
633633
return bundleId;
634634
}),
635635
);
636636
const prepareArtifact = vi.fn(async () => {
637637
const repopulate = Promise.resolve().then(async () => {
638-
nextResolution = 'com.example.stale-after-uninstall';
638+
nextResolution = 'com.example.stale-during-preparation';
639639
await resolveFuzzyTarget('Maps');
640640
});
641641
await repopulate;
@@ -670,9 +670,6 @@ test('clears a concurrently repopulated fuzzy resolution after a preparation-fai
670670
}),
671671
).rejects.toThrow('replacement artifact is invalid');
672672

673-
// The low-level uninstall scope clears its own cache, but a resolution racing artifact
674-
// preparation can repopulate it. The whole reinstall scope must clear that stale value even
675-
// when preparation fails before any install attempt.
676673
expect(cachedResolutions).toEqual(new Map());
677674
expect(withInvalidatedAppResolutionCache).toHaveBeenCalledOnce();
678675
expect(resolveFuzzyTarget).toHaveBeenCalledTimes(2);

‎test/integration/provider-scenarios/ios-lifecycle.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,10 @@ test('Provider-backed integration iOS physical reinstall uses scripted devicectl
412412
udid: PROVIDER_SCENARIO_IOS_REINSTALL_DEVICE.id,
413413
});
414414
assert.notEqual(corrupt.statusCode, 200, JSON.stringify(corrupt.json));
415-
assert.ok(corrupt.json?.error, JSON.stringify(corrupt.json));
415+
assert.match(
416+
corrupt.json?.error?.message ?? '',
417+
/End of central directory record signature not found/,
418+
);
416419
const laterCalls = appleTool.calls.slice(callsBeforeCorrupt);
417420
assert.equal(
418421
laterCalls.some((call) => call.includes('uninstall') || call.includes('install')),

‎website/docs/docs/commands.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ agent-device reinstall com.example.app ./build/MyApp.app --platform ios
685685
```
686686
687687
- `reinstall <app> <path>` uninstalls and installs in one command, for login/logout resets and deterministic test setup. Device coverage, formats, and remote upload match `install`.
688-
- On iOS, `reinstall` reads the new build before it removes the installed app, so a build that is invalid or unreadable leaves the app and its data in place. If the install itself fails after the uninstall, the app stays removed.
688+
- On iOS, replacement archives are unpacked before the installed app is removed. If unpacking fails, the app and its data stay in place. An invalid app bundle or another install failure after uninstall can still leave the app removed.
689689
690690
## App uninstall
691691

0 commit comments

Comments
 (0)