diff options
| author | Dax Raad <[email protected]> | 2025-11-22 17:32:53 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-11-22 17:32:53 -0500 |
| commit | 768c81cdfdda7b4de4c009ce05de7fd112edd81e (patch) | |
| tree | b75c32fc321a2a2adc496a3a9d78b011712e763f | |
| parent | bcea8ed593a253c020c180afcd98aa83334d6384 (diff) | |
| download | opencode-768c81cdfdda7b4de4c009ce05de7fd112edd81e.tar.gz opencode-768c81cdfdda7b4de4c009ce05de7fd112edd81e.zip | |
core: prevent concurrent bun package installs that could cause corruption or conflicts
| -rw-r--r-- | packages/opencode/src/bun/index.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts index 764be05ab..b739cd225 100644 --- a/packages/opencode/src/bun/index.ts +++ b/packages/opencode/src/bun/index.ts @@ -4,6 +4,7 @@ import { Log } from "../util/log" import path from "path" import { NamedError } from "../util/error" import { readableStreamToText } from "bun" +import { Lock } from "../util/lock" export namespace BunProc { const log = Log.create({ service: "bun" }) @@ -58,6 +59,9 @@ export namespace BunProc { ) export async function install(pkg: string, version = "latest") { + // Use lock to ensure only one install at a time + using _ = await Lock.write("bun-install") + const mod = path.join(Global.Path.cache, "node_modules", pkg) const pkgjson = Bun.file(path.join(Global.Path.cache, "package.json")) const parsed = await pkgjson.json().catch(async () => { |
