Skip to content

Commit

Permalink
add delay
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Feb 28, 2024
1 parent 86c7737 commit 1c93a9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helpers/dune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const getLatestData = async (queryId: string) => {
throw e;
}
}
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))

const inquiryStatus = async (queryId: string) => {
let _status = undefined;
Expand All @@ -40,6 +41,10 @@ const inquiryStatus = async (queryId: string) => {
"x-dune-api-key": API_KEYS[API_KEY_INDEX]
}
}))).state
if (['QUERY_STATE_PENDING', 'QUERY_STATE_EXECUTING'].includes(_status)) {
console.info(`waiting for query id ${queryId} to complete...`)
await delay(5000) // 5s
}
} catch (e: any) {
throw e;
}
Expand Down

0 comments on commit 1c93a9c

Please sign in to comment.