title: How to cancel all ongoing Promises at once
body: <p>Imagine a tool which issues hundreds of requests (<code>Promise</code>) through that function:</p>
  <pre class="lang-js prettyprint-override"><code>function send(requestPromise, successFn, failureFn) {
    incrementCounters();
    requestPromise()
      .then(response =&gt; successFn(response.headers, response.data))
      .catch(() =&gt; failureFn())
      .finally(() =&gt; decrementCounters());
  }
  </code></pre>
  <p>Now, imagine the contacted server decides to deny all subsequent requests due to the client hitting an <code>API-Rate Limit</code>.</p>
  <p>Assuming the client wants to stop waiting for all the requests: how can the client get all the ongoing Promises to fail?</p>
  <p>Thus, the constraints are:</p>
  <ul>
  <li>a response from the server should not be awaited (the <code>then()</code> should not be executed)</li>
  <li>the cancellation should trigger both the <code>catch()</code> and the <code>finally()</code> calls</li>
  <li>even a <code>Promise</code> which had been queued up but hasn't yet triggered a call to the server should be cancelled</li>
  </ul>