@@ -71,23 +71,25 @@ const killExecaProcess = async (execaProcess) => {
7171 *
7272 * @param {Object } ctx
7373 * @param {execa.ExecaChildProcess<string> } execaChildProcess
74- * @returns {() => void } Function that clears the interval that
74+ * @returns {() => Promise< void> } Function that clears the interval that
7575 * checks the context.
7676 */
7777const interruptExecutionOnError = ( ctx , execaChildProcess ) => {
78- let loopIntervalId
78+ let intervalId , killPromise
7979
8080 const loop = async ( ) => {
8181 if ( ctx . errors . size > 0 ) {
82- clearInterval ( loopIntervalId )
83- await killExecaProcess ( execaChildProcess )
82+ clearInterval ( intervalId )
83+ killPromise = killExecaProcess ( execaChildProcess )
84+ await killPromise
8485 }
8586 }
8687
87- loopIntervalId = setInterval ( loop , ERROR_CHECK_INTERVAL )
88+ intervalId = setInterval ( loop , ERROR_CHECK_INTERVAL )
8889
89- return ( ) => {
90- clearInterval ( loopIntervalId )
90+ return async ( ) => {
91+ clearInterval ( intervalId )
92+ await killPromise
9193 }
9294}
9395
@@ -155,7 +157,7 @@ export const resolveTaskFn = ({
155157
156158 const quitInterruptCheck = interruptExecutionOnError ( ctx , execaChildProcess )
157159 const result = await execaChildProcess
158- quitInterruptCheck ( )
160+ await quitInterruptCheck ( )
159161
160162 if ( result . failed || result . killed || result . signal != null ) {
161163 throw makeErr ( command , result , ctx )
0 commit comments