Skip to content

Commit c779ae7

Browse files
authored
Merge pull request #3356 from lidge-jun/codex/promote-preview-2410-v4
[WRONG BRANCH] release: v2.42.0-preview.20260903
2 parents 491ffcf + b064b8f commit c779ae7

3 files changed

Lines changed: 61 additions & 6 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bitkyc08/opencodex",
3-
"version": "2.41.0-preview.20260903",
3+
"version": "2.42.0-preview.20260903",
44
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
55
"type": "module",
66
"main": "./bin/package-main.mjs",

‎tests/cursor-stream-health.test.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,32 @@ describe("Cursor inbound stream-health watchdog (T04)", () => {
140140
stream.on("error", () => {});
141141
stream.respond({ ":status": 200, "content-type": "application/connect+proto" });
142142
stream.write(Buffer.from(textDeltaFrame("hi")));
143+
// 40ms, not 100ms.
144+
//
145+
// The silence clock below is 400ms, so a 100ms ping left a margin of four
146+
// ticks: miss three in a row and the SILENCE watchdog fires first, which
147+
// is a different error and a green-looking bug report. That is exactly what
148+
// happened on the v2.41.0 macOS runner -- the assertion wanted
149+
// "heartbeat-only" and got "no inbound frames for 1s before turnEnded".
150+
//
151+
// Nothing about the behaviour under test needs a slow ping: the point is
152+
// that heartbeats reset the silence clock and do NOT reset the
153+
// heartbeat-only clock. A tighter interval tests the same two clocks with
154+
// ten ticks of margin instead of four.
143155
const ping = setInterval(() => {
144156
try {
145157
stream.write(Buffer.from(heartbeatFrame()));
146158
stream.write(Buffer.from(checkpointFrame()));
147159
} catch { clearInterval(ping); }
148-
}, 100);
160+
}, 40);
149161
stream.on("close", () => clearInterval(ping));
150162
}, async baseUrl => {
151163
const { failure } = await drain(baseUrl, { streamSilenceFailMs: 400, streamHeartbeatOnlyFailMs: 900 });
152164
expect(failure).toBeDefined();
165+
// Assert on the message, and say which watchdog won when the wrong one does.
166+
// A bare toContain here reported only the expected substring, which reads as
167+
// "the heartbeat-only watchdog is broken" when the real story is that the
168+
// silence watchdog fired first on a loaded runner.
153169
expect(failure!.message).toContain("heartbeat-only");
154170
});
155171
}, 15_000);

‎tests/shutdown-launcher.test.ts‎

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ async function healthy(port: number): Promise<boolean> {
6767
}
6868
}
6969

70+
/**
71+
* Startup budget for the proxy, generous on CI and tight locally.
72+
*
73+
* The subject of this test is signal forwarding, not startup latency, so the
74+
* budget only has to be long enough that a slow machine does not read as an
75+
* orphaned proxy. Locally the spawn is healthy in ~800ms; a shared CI runner
76+
* building four shards plus a macOS suite in parallel is a different machine
77+
* entirely, and 20s was not enough for it twice on 2026-09-03.
78+
*
79+
* Raising this cannot hide the regression the test guards: an orphaned proxy
80+
* fails at step 4 (the port never frees), which has its own deadline. What a
81+
* too-short startup budget DOES hide is that distinction — it fails before the
82+
* shutdown path runs at all.
83+
*/
84+
const STARTUP_BUDGET_MS = process.env.CI ? 60_000 : 20_000;
85+
7086
async function waitUntil(fn: () => Promise<boolean>, deadlineMs: number): Promise<boolean> {
7187
const end = Date.now() + deadlineMs;
7288
while (Date.now() < end) {
@@ -91,8 +107,17 @@ describe.skipIf(!runnable)("ocx launcher graceful shutdown", () => {
91107
const codexConfig = join(home, "config.toml");
92108
writeFileSync(codexConfig, 'model = "gpt-5.1"\n');
93109

110+
// stdout/stderr are CAPTURED, not discarded.
111+
//
112+
// This test failed twice on the v2.41.0 promotion at exactly 20s -- the
113+
// startup deadline below, not the shutdown path this test is named for.
114+
// With `stdio: "ignore"` the failure said only `expect(up).toBe(true)`:
115+
// no proxy log, no exit code, no way to tell a slow runner from a real
116+
// startup regression. Locally the same spawn is healthy in ~800ms, so a
117+
// 25x margin is already generous and the missing evidence was the actual
118+
// problem.
94119
const child = spawn("node", [BIN_OCX, "start", "--port", String(port)], {
95-
stdio: "ignore",
120+
stdio: ["ignore", "pipe", "pipe"],
96121
env: {
97122
...process.env,
98123
HOME: identity.homeDir,
@@ -105,11 +130,25 @@ describe.skipIf(!runnable)("ocx launcher graceful shutdown", () => {
105130
spawned.push(child);
106131

107132
let exited = false;
133+
let exitCode: number | null = null;
134+
let exitSignal: NodeJS.Signals | null = null;
108135
child.on("exit", () => { exited = true; });
136+
child.on("exit", (code, sig) => { exitCode = code; exitSignal = sig; });
137+
138+
let output = "";
139+
child.stdout?.on("data", chunk => { output += String(chunk); });
140+
child.stderr?.on("data", chunk => { output += String(chunk); });
109141

110142
// 1. Proxy comes up + injected the Codex config (Design B root override on loopback).
111-
const up = await waitUntil(() => healthy(port), 20_000);
112-
expect(up).toBe(true);
143+
const up = await waitUntil(() => healthy(port), STARTUP_BUDGET_MS);
144+
if (!up) {
145+
// Name what actually went wrong instead of asserting a bare boolean.
146+
const died = exited ? ` The launcher EXITED (code ${exitCode}, signal ${exitSignal}).` : " The launcher was still running.";
147+
throw new Error(
148+
`The proxy never answered /healthz on port ${port} within ${STARTUP_BUDGET_MS}ms.${died}`
149+
+ ` Launcher output:\n${output.trim() || "(none)"}`,
150+
);
151+
}
113152
expect(existsSync(join(home, "ocx.pid"))).toBe(true);
114153
const injected = readFileSync(codexConfig, "utf8");
115154
expect(injected).toContain("# Auto-injected by opencodex");
@@ -132,7 +171,7 @@ describe.skipIf(!runnable)("ocx launcher graceful shutdown", () => {
132171
expect(existsSync(join(home, "runtime-port.json"))).toBe(false);
133172
expect(readFileSync(codexConfig, "utf8")).not.toContain("opencodex");
134173
},
135-
45_000,
174+
STARTUP_BUDGET_MS + 40_000,
136175
);
137176
}
138177
});

0 commit comments

Comments
 (0)