Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): OpenCodeServerLedger linux tests no longer race a wrapper's exec #22209

Closedjuliusmarmingewants to merge 1 commit intomain fromfix/opencode-ledger-flakeopened View on GitHub

Showing 2 changed files with 27 additions and 11 deletions.

x
0 of 2 viewed, 2 left
13 additions and 2 deletionspackages/provider-opencode/src/server/OpenCodeServerLedger.test.tsModified
View file
@@ -28,9 +28,14 @@
};
​
+// A group can empty between any check and the kill, so ESRCH means done.
const killGroup = (pgid: number) =>
Effect.sync(() => {
- if (groupExists(pgid)) process.kill(-pgid, "SIGKILL");
+ try {
+ process.kill(-pgid, "SIGKILL");
+ } catch (cause) {
+ if ((cause as NodeJS.ErrnoException).code !== "ESRCH") throw cause;
+ }
});
​
const spawnGroup = (args: ReadonlyArray<string>, script = "sleep 600 & wait") =>
@@ -96,15 +101,21 @@
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");
+ const ready = path.join(stateDir, "ready");
+ NodeChildProcess.execFileSync("mkfifo", [gate, ready]);
+ // The wrapper's child is recorded before it execs and stopped after.
const wrapper = yield* spawnGroup(
SERVE_ARGS,
- '/bin/sh -c "sleep 600 & wait" "$0" "$@" & exit 0',
+ `(read _ < '${gate}'; exec /bin/sh -c 'echo > "${ready}"; sleep 600 & wait' "$0" "$@") & exit 0`,