From c286c8a039757fa48033d6a5c82dcd8199c03750 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 9 Jun 2023 06:19:11 -0700 Subject: [PATCH] Sleep after creating a prediction before polling for updates --- lib/predictions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/predictions.js b/lib/predictions.js index 3ec8546..c5ffda9 100644 --- a/lib/predictions.js +++ b/lib/predictions.js @@ -21,6 +21,11 @@ async function createPrediction(options) { if (wait) { const { maxAttempts, interval } = wait; + + // eslint-disable-next-line no-promise-executor-return + const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + await sleep(interval || 250); + return this.wait(await prediction, { maxAttempts, interval }); }