Skip to content

Commit

Permalink
stop racing
Browse files Browse the repository at this point in the history
  • Loading branch information
ewansheldon committed Sep 25, 2023
1 parent 523e36e commit 22f0e51
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ const tenSecTimeout = _ => {

const retryableWithTimeout = async promise => {
try {
const start = Math.floor(new Date() / 1000);
const data = await Promise.race([promise, tenSecTimeout()]);
const end = Math.floor(new Date() / 1000);
console.log(`data fetched (${end - start}s)`);
return data;
return await promise;
} catch (e) {
console.log(e)
return await retryableWithTimeout(promise);
Expand Down

0 comments on commit 22f0e51

Please sign in to comment.