Skip to content

Commit

Permalink
fix: pRetry logFailures now correctly defaults to true
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jul 30, 2024
1 parent 0c046cd commit dc7f63b
Show file tree
Hide file tree
Showing 3 changed files with 427 additions and 440 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@naturalcycles/nodejs-lib": "^13.0.1",
"@naturalcycles/time-lib": "^3.5.1",
"@types/crypto-js": "^4.1.1",
"@types/node": "^20.1.0",
"@types/node": "^22.0.0",
"@types/semver": "^7.5.8",
"crypto-js": "^4.1.1",
"jest": "^29.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/promise/pRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function pRetry<T>(
} = opt

const fakeError = timeout ? new Error('TimeoutError') : undefined
let { logFirstAttempt = false, logRetries = true, logFailures = false, logSuccess = false } = opt
let { logFirstAttempt = false, logRetries = true, logFailures = true, logSuccess = false } = opt

if (opt.logAll) {
logSuccess = logFirstAttempt = logRetries = logFailures = true
Expand Down Expand Up @@ -157,7 +157,7 @@ export async function pRetry<T>(
return result
} catch (err) {
if (logFailures) {
logger.warn(`${fname} attempt #${attempt} error in ${_since(started)}:`, err)
logger.error(`${fname} attempt #${attempt} error in ${_since(started)}:`, err)
}

if (attempt >= maxAttempts || (predicate && !predicate(err as Error, attempt, maxAttempts))) {
Expand Down
Loading

0 comments on commit dc7f63b

Please sign in to comment.