Skip to content

Commit d27e8a0

Browse files
committed
test(apple): clear the wedged spawn's timeout when its signal aborts
1 parent 5acb488 commit d27e8a0

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎packages/platform-apple/src/launch-confirmation.test.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,17 @@ function wedgedCoreSimulator(): AppleToolProvider & { spawns: () => number } {
202202
const hang = async (options?: ExecOptions): Promise<ExecResult> =>
203203
await new Promise((_resolve, reject) => {
204204
spawns += 1;
205-
if (options?.timeoutMs) {
206-
setTimeout(() => reject(spawnTimeout()), options.timeoutMs);
207-
}
208-
options?.signal?.addEventListener('abort', () => reject(options.signal?.reason), {
209-
once: true,
210-
});
205+
const timer = options?.timeoutMs
206+
? setTimeout(() => reject(spawnTimeout()), options.timeoutMs)
207+
: undefined;
208+
options?.signal?.addEventListener(
209+
'abort',
210+
() => {
211+
clearTimeout(timer);
212+
reject(options.signal?.reason);
213+
},
214+
{ once: true },
215+
);
211216
});
212217
return {
213218
whichCommand: async () => true,

0 commit comments

Comments
 (0)