Skip to content

Commit

Permalink
fix: let AbortController API be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Apr 27, 2024
1 parent 351ba88 commit a21e1b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/ts/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a21e1b9

Please sign in to comment.