Favorites

JavaScript Promise.race() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Promise.race()
JavaScript Promise Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

The Promise.race() static method settles as soon as the first of several promises settles, whether it succeeds or fails. It's often used to add a timeout.

Description

The Promise.race() static method returns a promise that settles with the first input promise to settle, either fulfilling or rejecting. A common use is a timeout: race the real task against a promise that rejects after a delay.

If the iterable is empty, the returned promise stays pending forever. The "losing" promises aren't cancelled; they keep running and their results are simply ignored, so a timed-out fetch() still downloads in the background unless you abort it with an AbortController.

For timeouts on requests, AbortSignal.timeout(ms) passed as the signal option to fetch() is now a simpler alternative that also stops the request itself.

Syntax

Promise.race(iterable)

Parameters

  • iterableAn iterable of promises or values.

Return Value

A promise that settles in the same way as the first input promise to settle.

Example

const timeout = ms => new Promise((_, rej) => setTimeout(() => rej(new Error('Timed out')), ms));
const slowTask = new Promise(res => setTimeout(() => res('done'), 1000));

Promise.race([slowTask, timeout(300)])
  .then(console.log)
  .catch(err => console.log(err.message));

Browser Support

The following information will show you the current browser support for the Promise.race() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee