cancel.js
This file
Path
lib/terminate/cancel.js
25 lines · 1.1 KiB · JavaScript
Last changed by
Fix wrong-typed options and arguments being silently ignored or coercedSindre Sorhusbefore adoptionb57d643
History of this fileTake it
Fix wrong-typed options and arguments being silently ignored or coercedSindre Sorhusbefore adoptionb57d643
line 1why, one step back1import {onAbortedSignal, validateAbortSignal} from '../utils/abort-signal.js';Improve `cancelSignal` option (#1108)ehmickybefore adoption3b56977
lines 2–4why, one step back23// Validate the `cancelSignal` option4export const validateCancelSignal = ({cancelSignal}) => {Fix wrong-typed options and arguments being silently ignored or coercedSindre Sorhusbefore adoptionb57d643
line 5why, one step back5 validateAbortSignal(cancelSignal, 'cancelSignal');Improve `cancelSignal` option (#1108)ehmickybefore adoption3b56977
lines 6–7why, one step back6};7Fix the "signal" option being silently ignored by synchronous methodsSindre Sorhusbefore adoption59de065
lines 8–14why, one step back8// The `signal` option was renamed to `cancelSignal`. Validated for every method, otherwise synchronous methods would silently ignore it, since `child_process.spawnSync()` does not support that option either.9export const validateRenamedSignalOption = ({signal}) => {10 if (signal !== undefined) {11 throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');12 }13};14Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 15why, one step back15// Terminate the subprocess when aborting the `cancelSignal` option and `gracefulSignal` is `false`Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 16why, one step back16export const throwOnCancel = ({kill, cancelSignal, gracefulCancel, context, controller}) => cancelSignal === undefined || gracefulCancelImprove `cancelSignal` option (#1108)ehmickybefore adoption3b56977
line 17why, one step back17 ? []Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 18why, one step back18 : [terminateOnCancel(kill, cancelSignal, context, controller)];Improve `cancelSignal` option (#1108)ehmickybefore adoption3b56977
line 19why, one step back19Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 20why, one step back20const terminateOnCancel = async (kill, cancelSignal, context, {signal}) => {Improve `cancelSignal` option (#1108)ehmickybefore adoption3b56977
line 21why, one step back21 await onAbortedSignal(cancelSignal, signal);Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5
line 22why, one step back22 context.terminationReason ??= 'cancel';Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf
line 23why, one step back23 kill();Improve `cancelSignal` option (#1108)ehmickybefore adoption3b56977
lines 24–25why, one step back24 throw cancelSignal.reason;25};