Commit b684d0c
Changed files (2)
src/experimental.ts
@@ -43,13 +43,13 @@ export async function retry<T>(
try {
return await callback()
} catch (err) {
- if ($.verbose) {
- console.error(
- chalk.bgRed.white(' FAIL '),
- `Attempt: ${total - count}/${total}` +
- (delay > 0 ? `; next in ${delay}ms` : '')
- )
- }
+ $.log({
+ kind: 'retry',
+ error:
+ chalk.bgRed.white(' FAIL ') +
+ ` Attempt: ${total - count}/${total}` +
+ (delay > 0 ? `; next in ${delay}ms` : ''),
+ })
lastErr = err
if (count == 0) break
if (delay) await sleep(delay)
src/log.ts
@@ -38,6 +38,10 @@ export type LogEntry =
url: RequestInfo
init?: RequestInit
}
+ | {
+ kind: 'retry'
+ error: string
+ }
| {
kind: 'custom'
data: any
@@ -65,5 +69,8 @@ export function log(entry: LogEntry) {
'$ ' + chalk.greenBright('fetch') + ` ${entry.url}${init}\n`
)
break
+ case 'retry':
+ if (!$.verbose) return
+ process.stderr.write(entry.error + '\n')
}
}