fix(server): [Windows] bound child process shutdown #6318
ClosedDefmon3(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/6318/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- @@ -0,0 +1,15 @@1+import { NodeServices } from "@effect/platform-node";2+import { expect, it } from "@effect/vitest";3+import * as Deferred from "effect/Deferred";4+import * as Effect from "effect/Effect";5+import * as Exit from "effect/Exit";6+import * as Fiber from "effect/Fiber";7+import * as Layer from "effect/Layer";8+import * as Option from "effect/Option";9+import * as Scope from "effect/Scope";10+import * as Sink from "effect/Sink";11+import * as Stream from "effect/Stream";12+import { TestClock } from "effect/testing";13+import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";14+15+import { layer, make, type ChildProcessShutdownSignal } from "./boundedChildProcessSpawner.ts";
- apps/server/src/bin.ts line 22Outdated@@ -11,10 +11,12 @@1111 import { connectCommand } from "./cli/connect.ts";1212 import { pairCommand } from "./cli/pair.ts";1313 import { hasCloudPublicConfig } from "./cloud/publicConfig.ts";14+import * as BoundedChildProcessSpawner from "./cli/boundedChildProcessSpawner.ts";1415 import { sharedServerCommandFlags } from "./cli/config.ts";1516 import { projectCommand } from "./cli/project.ts";1617 import { runServerCommand, serveCommand, startCommand } from "./cli/server.ts";1718 import { serviceCommand } from "./cli/service.ts";1819 import { servicePreflightCommand } from "./cli/servicePreflight.ts";192020-const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, NetService.layer);21+const CliRuntimeLayer = Layer.mergeAll(22+ process.platform === "win32"
- @@ -11,10 +11,16 @@1111 import { connectCommand } from "./cli/connect.ts";1212 import { pairCommand } from "./cli/pair.ts";1313 import { hasCloudPublicConfig } from "./cloud/publicConfig.ts";14+import * as BoundedChildProcessSpawner from "./cli/boundedChildProcessSpawner.ts";1415 import { sharedServerCommandFlags } from "./cli/config.ts";1516 import { projectCommand } from "./cli/project.ts";1617 import { runServerCommand, serveCommand, startCommand } from "./cli/server.ts";1718 import { serviceCommand } from "./cli/service.ts";1819 import { servicePreflightCommand } from "./cli/servicePreflight.ts";192020-const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, NetService.layer);21+const CliRuntimeLayer = Layer.mergeAll(22+ process.platform === "win32"23+ ? BoundedChildProcessSpawner.layer().pipe(Layer.provideMerge(NodeServices.layer))24+ : NodeServices.layer,25+ NetService.layer,26+);
- apps/server/src/cli/boundedChildProcessSpawner.ts line 133OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +113,21 @@113+ Effect.suspend(() =>114+ callerScope.state._tag === "Closed"115+ ? killOnceForShutdown(killOptions)116+ : delegateHandle.kill(killOptions),117+ ),118+ stdin: delegateHandle.stdin,119+ stdout: delegateHandle.stdout,120+ stderr: delegateHandle.stderr,121+ all: delegateHandle.all,122+ getInputFd: delegateHandle.getInputFd,123+ getOutputFd: delegateHandle.getOutputFd,124+ unref: delegateHandle.unref.pipe(125+ Effect.tap(() =>126+ Effect.sync(() => {127+ referenced = false;128+ }),129+ ),130+ Effect.map((reref) =>131+ reref.pipe(132+ Effect.tap(() =>133+ Effect.sync(() => {
Defmon3(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Approvability#
Verdict: Needs human review
This PR introduces a new Windows-specific child process management capability (~500 lines) that changes how processes are terminated with bounded shutdown behavior. New runtime behavior like process lifecycle management warrants human review.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).