Rejects with a [[TimeoutError]] if promise doesn't settle within ms milliseconds.
promise
ms
The original promise still runs to completion — there's no cancellation primitive in JS — but the returned promise won't wait for it.
await timeout(fetch('/slow'), 5000) Copy
await timeout(fetch('/slow'), 5000)
Rejects with a [[TimeoutError]] if
promisedoesn't settle withinmsmilliseconds.The original promise still runs to completion — there's no cancellation primitive in JS — but the returned promise won't wait for it.