diff options
| author | Aiden Cline <[email protected]> | 2025-11-19 13:04:20 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2025-11-19 13:04:20 -0600 |
| commit | 48e4f2f45d54364a8123d603dbbca7bfe8fcc763 (patch) | |
| tree | 20b91b86c8d5c54063575b5f8bfc65d82531888d | |
| parent | bbf457447687b173a070e9bf0634ee77b66f7a00 (diff) | |
| download | opencode-48e4f2f45d54364a8123d603dbbca7bfe8fcc763.tar.gz opencode-48e4f2f45d54364a8123d603dbbca7bfe8fcc763.zip | |
tweak: add bun install retries
| -rw-r--r-- | packages/opencode/src/bun/index.ts | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts index 5f1847275..764be05ab 100644 --- a/packages/opencode/src/bun/index.ts +++ b/packages/opencode/src/bun/index.ts @@ -79,16 +79,48 @@ export namespace BunProc { version, }) - await BunProc.run(args, { - cwd: Global.Path.cache, - }).catch((e) => { - throw new InstallFailedError( - { pkg, version }, - { - cause: e, - }, - ) - }) + const total = 3 + const wait = 500 + + const runInstall = async (count: number = 1): Promise<void> => { + log.info("bun install attempt", { + pkg, + version, + attempt: count, + total, + }) + await BunProc.run(args, { + cwd: Global.Path.cache, + }).catch(async (error) => { + log.warn("bun install failed", { + pkg, + version, + attempt: count, + total, + error, + }) + if (count >= total) { + throw new InstallFailedError( + { pkg, version }, + { + cause: error, + }, + ) + } + const delay = wait * count + log.info("bun install retrying", { + pkg, + version, + next: count + 1, + delay, + }) + await Bun.sleep(delay) + return runInstall(count + 1) + }) + } + + await runInstall() + parsed.dependencies[pkg] = version await Bun.write(pkgjson.name!, JSON.stringify(parsed, null, 2)) return mod |
