Promises | run any promise with a timeout

A promise has two states: either pending or settled (resolved or rejected). The user has no control over the time it takes from going from the first state to the second. Which makes it harder to bail out on a certain promise when it takes too long in a promise friendly way. Promise.race() to the rescue. Table of contents How does Promise.race work? This method takes an array of promises and - as its name suggests - races them, the first one to be settled in either state wins....

March 18, 2022 · 3 min · 468 words · Abdellah Hariti