Skip to content

Commit ab459da

Browse files
committed
fix: preserve Apple shutdown cancellation
1 parent 21d2bcf commit ab459da

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,27 @@ test('a shutdown error is successful when final simulator state is Shutdown', as
5151
);
5252
});
5353

54+
test('cancellation during the final simulator-state probe is not swallowed', async () => {
55+
const device = appleDevice();
56+
const controller = new AbortController();
57+
run
58+
.mockResolvedValueOnce({
59+
stdout: '',
60+
stderr: 'shutdown failed',
61+
exitCode: 149,
62+
})
63+
.mockImplementationOnce(async () => {
64+
controller.abort();
65+
throw controller.signal.reason;
66+
});
67+
const runtime = createAppleShutdownRuntime({ appleTools });
68+
69+
await expect(runtime.shutdownTarget(device, controller.signal)).rejects.toMatchObject({
70+
name: 'AbortError',
71+
});
72+
expect(run).toHaveBeenCalledTimes(2);
73+
});
74+
5475
test('watchOS and non-simulator Apple targets are unavailable', () => {
5576
expect(canShutdownTarget(appleDevice())).toBe(true);
5677
expect(canShutdownTarget(appleDevice({ appleOs: 'watchos' }))).toBe(false);

‎packages/platform-apple/src/shutdown/runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ async function finalSimulatorState(
7272
try {
7373
return await getSimulatorState(appleTools, device, signal, SHUTDOWN_TIMEOUT_MS);
7474
} catch {
75+
signal.throwIfAborted();
7576
return null;
7677
}
7778
}

0 commit comments

Comments
 (0)