summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2026-04-17 14:18:48 -0400
committerDax Raad <[email protected]>2026-04-17 14:18:48 -0400
commit992435aaf8371dc784f9f3489e998e5c93451d18 (patch)
tree8626c82802d32a1f60a6b746a95a5a68f2ff8183
parent2f73e73e9d03262fb59d4e942b3e1e073cb76cb9 (diff)
downloadopencode-992435aaf8371dc784f9f3489e998e5c93451d18.tar.gz
opencode-992435aaf8371dc784f9f3489e998e5c93451d18.zip
do not flock until reify
-rw-r--r--packages/opencode/src/npm/effect.ts63
1 files changed, 30 insertions, 33 deletions
diff --git a/packages/opencode/src/npm/effect.ts b/packages/opencode/src/npm/effect.ts
index 10b5ff179..5968f1451 100644
--- a/packages/opencode/src/npm/effect.ts
+++ b/packages/opencode/src/npm/effect.ts
@@ -63,36 +63,6 @@ interface ArboristTree {
edgesOut: Map<string, { to?: ArboristNode }>
}
-const reify = (input: { dir: string; add?: string[] }) =>
- Effect.gen(function* () {
- const { Arborist } = yield* Effect.promise(() => import("@npmcli/arborist"))
- const arborist = new Arborist({
- path: input.dir,
- binLinks: true,
- progress: false,
- savePrefix: "",
- ignoreScripts: true,
- })
- return yield* Effect.tryPromise({
- try: () =>
- arborist.reify({
- add: input?.add || [],
- save: true,
- saveType: "prod",
- }),
- catch: (cause) =>
- new InstallFailedError({
- cause,
- add: input?.add,
- dir: input.dir,
- }),
- }) as Effect.Effect<ArboristTree, InstallFailedError>
- }).pipe(
- Effect.withSpan("Npm.reify", {
- attributes: input,
- }),
- )
-
export const layer = Layer.effect(
Service,
Effect.gen(function* () {
@@ -101,6 +71,36 @@ export const layer = Layer.effect(
const fs = yield* FileSystem.FileSystem
const flock = yield* EffectFlock.Service
const directory = (pkg: string) => path.join(global.cache, "packages", sanitize(pkg))
+ const reify = (input: { dir: string; add?: string[] }) =>
+ Effect.gen(function* () {
+ yield* flock.acquire(`npm-install:${input.dir}`)
+ const { Arborist } = yield* Effect.promise(() => import("@npmcli/arborist"))
+ const arborist = new Arborist({
+ path: input.dir,
+ binLinks: true,
+ progress: false,
+ savePrefix: "",
+ ignoreScripts: true,
+ })
+ return yield* Effect.tryPromise({
+ try: () =>
+ arborist.reify({
+ add: input?.add || [],
+ save: true,
+ saveType: "prod",
+ }),
+ catch: (cause) =>
+ new InstallFailedError({
+ cause,
+ add: input?.add,
+ dir: input.dir,
+ }),
+ }) as Effect.Effect<ArboristTree, InstallFailedError>
+ }).pipe(
+ Effect.withSpan("Npm.reify", {
+ attributes: input,
+ }),
+ )
const outdated = Effect.fn("Npm.outdated")(function* (pkg: string, cachedVersion: string) {
const response = yield* Effect.tryPromise({
@@ -130,7 +130,6 @@ export const layer = Layer.effect(
const add = Effect.fn("Npm.add")(function* (pkg: string) {
const dir = directory(pkg)
- yield* flock.acquire(`npm-install:${dir}`)
const tree = yield* reify({ dir, add: [pkg] })
const first = tree.edgesOut.values().next().value?.to
@@ -145,8 +144,6 @@ export const layer = Layer.effect(
)
if (!canWrite) return
- yield* flock.acquire(`npm-install:${dir}`)
-
yield* Effect.gen(function* () {
const nodeModulesExists = yield* afs.existsSafe(path.join(dir, "node_modules"))
if (!nodeModulesExists) {