Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BLO-769] Make wait time dynamic to speed up QA and testing work #1844

Merged
merged 5 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/extension/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ARGENT_X_STATUS_URL=
#ARGENT_SHIELD_NETWORK_ID=
#FEATURE_MULTISIG=
#FEATURE_VERIFIED_DAPPS=
#WAIT_TIME=
diegodelrieu marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 9 additions & 7 deletions packages/extension/src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ browser.alarms.onAlarm.addListener(async (alarm) => {
let hasInFlightTransactions = await transactionTracker.update()

// the config below will run transaction updates 4x per minute, if there are in-flight transactions
// it will update on second 0, 15, 30 and 45
const maxRetries = 3 // max 3 retries
const waitTimeInS = 15 // wait 15 seconds between retries

let runs = 0
while (hasInFlightTransactions && runs < maxRetries) {
// By default it will update on second 0, 15, 30 and 45 but by updating WAIT_TIME we can change the number of executions
const maxExecutionTimeInMs = 60000 // 1 minute max execution time
const waitTimeInS = parseInt(process.env.WAIT_TIME ?? "15") // use environment variable for wait time, default to 15 seconds
const startTime = Date.now()

while (
hasInFlightTransactions &&
Date.now() - startTime < maxExecutionTimeInMs
) {
console.info(`~> waiting ${waitTimeInS}s for transaction updates`)
await delay(waitTimeInS * 1000)
console.info(
"~> fetching transaction updates as pending transactions were detected",
)
runs++
hasInFlightTransactions = await transactionTracker.update()
}
}
Expand Down