Repository navigation
Open
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
Not sure
Steps to reproduce
- Start an OpenCode thread and ask it to run a long-lived shell command.
- Terminate T3 Code without a graceful shutdown while the command is running.
- Terminate the leftover OpenCode server process while leaving its shell child running.
- Restart T3 Code with the same home directory.
Expected behavior
Restarting T3 Code cleans up shell commands left behind by its previous OpenCode server.
Actual behavior
The shell command keeps running after restart, and its cleanup record is deleted so later restarts cannot stop it.
Impact
Major degradation or frequent failure. Users whose T3 Code crashes and whose OpenCode server exits before restart can be left with untracked shell commands consuming resources until they exit or are stopped manually.
Version or commit
main at ca432d7ed6. The cause is at packages/provider-opencode/src/server/OpenCodeServerLedger.ts:254.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
expected true to be falseAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/packages/provider-opencode/src/server/OpenCodeServerLedger.test.ts b/packages/provider-opencode/src/server/OpenCodeServerLedger.test.ts
index 3fcb52c898..56e865723a 100644
--- a/packages/provider-opencode/src/server/OpenCodeServerLedger.test.ts
+++ b/packages/provider-opencode/src/server/OpenCodeServerLedger.test.ts
@@ -143,6 +143,27 @@ describe.each(observedPlatforms)("OpenCodeServerLedger observing as %s", (platfo
}).pipe(provideHost),
);
+ it.live("stops surviving shell children when the recorded server exits before restart", () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const stateDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-opencode-ledger-" });
+ const gate = path.join(stateDir, "gate");
+ NodeChildProcess.execFileSync("mkfifo", [gate]);
+ const server = yield* spawnGroup(SERVE_ARGS, `sleep 600 & read _ < '${gate}'; exit 0`);
+ yield* recordFromDeadServer(stateDir, server);
+ yield* fs.writeFileString(gate, "\n");
+ yield* server.exited;
+ expect(groupExists(server.pid)).toBe(true);
+
+ const restarted = yield* OpenCodeServerLedger.make({ stateDir });
+ yield* restarted.reapOrphans;
+
+ expect(yield* fs.readDirectory(path.join(stateDir, "opencode-servers"))).toEqual([]);
+ expect(groupExists(server.pid)).toBe(false);
+ }).pipe(provideHost),
+ );
+
it.live("records a group whose spawned wrapper already exited", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;cd packages/provider-opencode && pnpm exec vp test run --config ../../vite.config.ts src/server/OpenCodeServerLedger.test.ts -t 'stops surviving shell children'Workaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity