diff --git a/packages/utils/src/promise.ts b/packages/utils/src/promise.ts index bfc5b5a3ed6c..51e1cdbaf1e3 100644 --- a/packages/utils/src/promise.ts +++ b/packages/utils/src/promise.ts @@ -80,14 +80,12 @@ export async function racePromisesWithCutoff( ): Promise<(Error | T)[]> { // start the cutoff and timeout timers let cutoffObserved = false; - const cutoffPromise = new Promise((_resolve, reject) => setTimeout(reject, cutoffMs)).catch((e) => { + const cutoffPromise = sleep(cutoffMs).then(() => { cutoffObserved = true; - throw e; }); let timeoutObserved = false; - const timeoutPromise = new Promise((_resolve, reject) => setTimeout(reject, timeoutMs)).catch((e) => { + const timeoutPromise = sleep(timeoutMs).then(() => { timeoutObserved = true; - throw e; }); const startTime = Date.now();