Skip to content

Commit 0b927cb

Browse files
Apply PR #18798: fix: restore cross-spawn behavior for effect child processes
2 parents 3cb7913 + 5da672b commit 0b927cb

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

packages/opencode/src/installation/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { NodeChildProcessSpawner, NodeFileSystem, NodePath } from "@effect/platform-node"
1+
import { NodeFileSystem, NodePath } from "@effect/platform-node"
22
import { Effect, Layer, Schema, ServiceMap, Stream } from "effect"
33
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http"
4+
import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner"
45
import { makeRuntime } from "@/effect/run-service"
56
import { withTransientReadRetry } from "@/util/effect-http-client"
67
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
@@ -340,7 +341,7 @@ export namespace Installation {
340341

341342
export const defaultLayer = layer.pipe(
342343
Layer.provide(FetchHttpClient.layer),
343-
Layer.provide(NodeChildProcessSpawner.layer),
344+
Layer.provide(CrossSpawnSpawner.layer),
344345
Layer.provide(NodeFileSystem.layer),
345346
Layer.provide(NodePath.layer),
346347
)

packages/opencode/src/snapshot/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { NodeChildProcessSpawner, NodeFileSystem, NodePath } from "@effect/platform-node"
1+
import { NodeFileSystem, NodePath } from "@effect/platform-node"
22
import { Cause, Duration, Effect, Layer, Schedule, ServiceMap, Stream } from "effect"
33
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
44
import path from "path"
55
import z from "zod"
6+
import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner"
67
import { InstanceState } from "@/effect/instance-state"
78
import { makeRuntime } from "@/effect/run-service"
89
import { AppFileSystem } from "@/filesystem"
@@ -354,9 +355,9 @@ export namespace Snapshot {
354355
)
355356

356357
export const defaultLayer = layer.pipe(
357-
Layer.provide(NodeChildProcessSpawner.layer),
358+
Layer.provide(CrossSpawnSpawner.layer),
358359
Layer.provide(AppFileSystem.defaultLayer),
359-
Layer.provide(NodeFileSystem.layer), // needed by NodeChildProcessSpawner
360+
Layer.provide(NodeFileSystem.layer), // needed by CrossSpawnSpawner
360361
Layer.provide(NodePath.layer),
361362
)
362363

packages/opencode/test/effect/cross-spawn-spawner.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ describe("cross-spawn spawner", () => {
305305
test("returns empty stream for unconfigured fd", async () => {
306306
const out = await runScoped(
307307
Effect.gen(function* () {
308-
const handle = yield* ChildProcess.make("echo", ["test"])
308+
const handle = yield* ChildProcess.make("sh", ["-c", "echo test"])
309309
const fd3Output = yield* decodeByteStream(handle.getOutputFd(3))
310310
yield* handle.exitCode
311311
return fd3Output
@@ -342,7 +342,10 @@ describe("cross-spawn spawner", () => {
342342
const handle = yield* ChildProcess.make("sh", ["-c", "seq 1 100000"])
343343
const output = yield* handle.stdout.pipe(
344344
Stream.decodeText(),
345-
Stream.runFold(() => "", (acc, chunk) => acc + chunk),
345+
Stream.runFold(
346+
() => "",
347+
(acc, chunk) => acc + chunk,
348+
),
346349
)
347350
yield* handle.exitCode
348351
return output

0 commit comments

Comments
 (0)