Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): restarted server stops an orphaned OpenCode server started through a wrapper #34959

Mergedjuliusmarmingemerged 5 commits intomain fromrefs/pull/34959/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 53 additions and 15 deletions.

x
0 of 2 viewed, 2 left
41 additions and 10 deletionspackages/provider-opencode/src/server/OpenCodeServerLedger.test.tsModified
View file
@@ -56,7 +56,6 @@
if (pid === undefined) return yield* Effect.die("spawn failed");
const grouped = yield* Deferred.make<true | string>();
const exited = yield* Deferred.make<NodeJS.Signals | null>();
- const printed = yield* Deferred.make<void>();
child.once("exit", (_code, signal) => Deferred.doneUnsafe(exited, Effect.succeed(signal)));
// "close" fires after stdout drains, so a guard line always lands first. It only fires before
// "grouped" when the shell died without starting the script, such as from a signal.
@@ -77,12 +76,9 @@
Effect.succeed(`\`ps -o pgid= -p ${pid}\` printed ${JSON.stringify(output)}`),
);
- if (line === "ready") Deferred.doneUnsafe(printed, Effect.void);
});
const result = yield* Deferred.await(grouped);
- return result === true
- ? { pid, exited: Deferred.await(exited), printed: Deferred.await(printed) }
- : result;
+ return result === true ? { pid, exited: Deferred.await(exited) } : result;
});
​
// A pid colliding with a live group id is rare, so a few retries clear it. Repeated failures
@@ -152,18 +148,21 @@
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const stateDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-opencode-ledger-" });
- // The inner shell prints once it has exec'd. Until then it still carries the wrapper's
- // command line, and recording that would make the reaper skip the group as recycled.