Promise-returning delay function

Cyril Auburtin cyril.auburtin at
Sun Dec 27 17:56:09 UTC 2020

Follow up on

I think we really need that function, with AbortController support

We could do things like

const abortFetch = new AbortController();
const abortTimeout = new AbortController();

await Promise.race([
  Promise.delay(5000, {signal: abortTimeout.signal}),
  fetch(url, {signal: abortFetch.signal}).then(r => r.json()).then(...),
  .finally(() => {
    abortTimeout.abort(); // avoid mem leaks, that would call clearTimeout
under the hood
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list