diff --git a/node-src/tasks/build.ts b/node-src/tasks/build.ts index 11a74f16a..de3d69ce1 100644 --- a/node-src/tasks/build.ts +++ b/node-src/tasks/build.ts @@ -69,22 +69,15 @@ export const buildStorybook = async (ctx: Context) => { logFile.on('error', reject); }); - const { experimental_abortSignal: abortSignal } = ctx.options; - + const { experimental_abortSignal: signal } = ctx.options; try { const { command } = ctx.spawnParams; ctx.log.debug('Using spawnParams:', JSON.stringify(ctx.spawnParams, null, 2)); - let subprocess = null; - if (abortSignal) { - abortSignal.onabort = () => { - subprocess?.kill('SIGTERM', { forceKillAfterTimeout: 2000 }); - }; - } - subprocess = execaCommand(command, { stdio: [null, logFile, logFile] }); + const subprocess = execaCommand(command, { stdio: [null, logFile, logFile], signal }); await Promise.race([subprocess, timeoutAfter(ctx.env.STORYBOOK_BUILD_TIMEOUT)]); } catch (e) { - abortSignal?.throwIfAborted(); + signal?.throwIfAborted(); const buildLog = readFileSync(ctx.buildLogFile, 'utf8'); ctx.log.error(buildFailed(ctx, e, buildLog));