refactor: use promisified setTimeout in read retry

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5341/head
Divyansh Singh 1 week ago
parent bf8b6585f6
commit 4bb26cbedc

@ -1,4 +1,5 @@
import { readFile as fsReadFile } from 'node:fs/promises'
import { setTimeout } from 'node:timers/promises'
const retryCodes = new Set(['EMFILE', 'ENFILE'])
@ -13,7 +14,7 @@ export async function readFile(file: string): Promise<string> {
} catch (e) {
const code = (e as NodeJS.ErrnoException).code
if (attempt >= 9 || !code || !retryCodes.has(code)) throw e
await new Promise((resolve) => setTimeout(resolve, 2 ** attempt * 10))
await setTimeout(2 ** attempt * 10)
}
}
}

Loading…
Cancel
Save