From a21e1b94d1e7f15c1adc0c5bc7d951901cc87bca Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sat, 27 Apr 2024 13:57:22 +0300 Subject: [PATCH] fix: let AbortController API be optional --- src/main/ts/spawn.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/ts/spawn.ts b/src/main/ts/spawn.ts index 695e1c7..2915ac1 100644 --- a/src/main/ts/spawn.ts +++ b/src/main/ts/spawn.ts @@ -73,8 +73,8 @@ export const normalizeCtx = (...ctxs: TSpawnCtx[]): TSpawnCtxNormalized => assig input: null, env: process.env, ee: new EventEmitter(), - ac: new AbortController(), - get signal() { return this.ac.signal }, + ac: AbortController && new AbortController(), + get signal() { return this.ac?.signal }, on: {}, detached: process.platform !== 'win32', shell: true, @@ -169,7 +169,7 @@ export const invoke = (c: TSpawnCtxNormalized): TSpawnCtxNormalized => { c.ee.emit('start', child, c) - opts.signal.addEventListener('abort', event => { + opts.signal?.addEventListener('abort', event => { if (opts.detached && child.pid) { try { // https://github.com/nodejs/node/issues/51766