Skip to content

Commit f66b17f

Browse files
committed
fix(server): provider update commands get no stdin, so one that reads it fails fast
1 parent 8ee7183 commit f66b17f

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎apps/server/src/provider/providerMaintenanceRunner.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as NodeServices from "@effect/platform-node/NodeServices";
12
import { describe, it, assert } from "@effect/vitest";
23
import {
34
ProviderDriverKind,
@@ -560,6 +561,43 @@ describe("providerMaintenanceRunner", () => {
560561
);
561562
});
562563

564+
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
565+
"runs the updater with no stdin, so a command that reads it cannot wait forever",
566+
() =>
567+
Effect.gen(function* () {
568+
const { registry } = yield* makeRegistry(baseProvider);
569+
const updater = yield* makeTestRunner({
570+
...registry,
571+
getProviderMaintenanceCapabilitiesForInstance: (_instanceId, provider) =>
572+
Effect.succeed({
573+
...lifecycleFor(provider),
574+
update: {
575+
command: "codex update",
576+
executable: "/bin/sh",
577+
// An open pipe here would block a CLI that reads stdin until the update times out.
578+
args: ["-c", "[ -c /dev/stdin ] || { echo 'stdin is an open pipe' >&2; exit 1; }"],
579+
lockKey: "codex-native",
580+
},
581+
}),
582+
});
583+
584+
const result = yield* updater.updateProvider(CODEX_DRIVER);
585+
// The registry reports no new version, so a command that exits 0 ends as "unchanged".
586+
assert.strictEqual(
587+
result.providers[0]?.updateState?.message,
588+
"Update command completed, but T3 Code still detects an outdated provider version.",
589+
);
590+
}).pipe(
591+
Effect.provide(
592+
Layer.mergeAll(
593+
NodeServices.layer,
594+
layerNonWindowsPlatform,
595+
layerLatestVersionHttpClient("1.0.0"),
596+
),
597+
),
598+
),
599+
);
600+
563601
it.effect("re-resolves ownership before running and executes the fresh command", () => {
564602
const calls: Array<{ command: string; args: ReadonlyArray<string> }> = [];
565603
const fresh: Array<boolean> = [];

‎apps/server/src/provider/providerMaintenanceRunner.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ const runProviderMaintenanceCommandWithSpawner = Effect.fn("ProviderMaintenanceR
111111
.spawn(
112112
ChildProcess.make(resolved.command, resolved.args, {
113113
shell: resolved.shell,
114+
// Nothing answers an update command, so one that reads stdin must see EOF, not wait.
115+
stdin: "ignore",
114116
...env,
115117
}),
116118
)

0 commit comments

Comments
 (0)