title: Kill an unresolved promise (or ignore and move on)
body: <p>Using node child process <code>exec</code>, I'm calling a ffmpeg conversion via a promise that takes a bit of time. Each time the use clicks "next" it starts the FFMpeg command on a new file:</p>
  
  <pre><code>function doFFMpeg(path){
    return new Promise((resolve, reject) =&gt; {
      exec('ffmpeg (long running command)', (error, stdout, stderr) =&gt; {
        if (error) {
          reject();
        }
      }).on('exit', (code) =&gt; { // Exit returns code 0 for good 1 bad
        if (code) {
          reject();
        } else {
          resolve();
        }
      });
    });
  }
  </code></pre>
  
  <p>The problem is, if the user moves on to the next video before the promise is returned, I need to scrap the process and move on to converting the next video.</p>
  
  <p>How do I either:</p>
  
  <p>A) (Ideally) Cancel the current promised exec process*
  B) Let the current promised exec process complete, but just ignore that promise while I start a new one.</p>
  
  <p>*I realize that promise.cancel <a href="https://stackoverflow.com/questions/30233302/promise-is-it-possible-to-force-cancel-a-promise">is not yet in ECMA</a>, but I'd like to know of a workaround -- preferably without using a 3rd party module / library.</p>
  
  <p><strong>Attempt:</strong></p>
  
  <pre><code>let myChildProcess;
  
  function doFFMpeg(path){
  
    myChildProcess.kill();
  
    return new Promise((resolve, reject) =&gt; {
      myChildProcess = exec('ffmpeg (long running command)', (error, stdout, stderr) =&gt; {
        if (error) {
          reject();
        }
      }).on('exit', (code) =&gt; { // Exit returns code 0 for good 1 bad
        if (code) {
          reject();
        } else {
          resolve();
        }
      });
    });
  }
  </code></pre>