-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(server): OCX_PROBE_TIMEOUT_MS override for liveness probe ceilings #5409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+171
−3
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /** | ||
| * OCX_PROBE_TIMEOUT_MS wiring test. The probe ceilings are module-load constants, | ||
| * so their value depends on the environment at the moment proxy-liveness is first | ||
| * evaluated. Bun's test files can share one module registry, which makes in-process | ||
| * env mutation order-dependent — instead of spawning a child interpreter, each case | ||
| * imports the module through a distinct query string: a different specifier is a | ||
| * different module instance per ESM resolution rules, so the module body (and the | ||
| * env read at its top level) re-runs under the environment this test just set. | ||
| * The variable is saved and restored around every case so no other test in a shared | ||
| * registry can observe a leftover value at its own first module load. | ||
| */ | ||
| import { afterEach, describe, expect, test } from "bun:test"; | ||
|
|
||
| const previousOverride = process.env.OCX_PROBE_TIMEOUT_MS; | ||
|
|
||
| afterEach(() => { | ||
| if (previousOverride === undefined) delete process.env.OCX_PROBE_TIMEOUT_MS; | ||
| else process.env.OCX_PROBE_TIMEOUT_MS = previousOverride; | ||
| }); | ||
|
|
||
| describe("OCX_PROBE_TIMEOUT_MS override wiring", () => { | ||
| test("defaults load when the variable is unset", async () => { | ||
| delete process.env.OCX_PROBE_TIMEOUT_MS; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=defaults"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(750); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(1500); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(1500); | ||
| }); | ||
|
|
||
| test("an override above both defaults raises every ceiling", async () => { | ||
| process.env.OCX_PROBE_TIMEOUT_MS = "3210"; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=raise-all"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(3210); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(3210); | ||
| expect(mod.SERVICE_STOP_LIVENESS.attempts).toBe(3); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(3210); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.attempts).toBe(3); | ||
| }); | ||
|
|
||
| test("an override between the two defaults raises only the shared default", async () => { | ||
| // 1000 lengthens the 750ms default but must NOT shorten the 1500ms stop/start | ||
| // budgets — those exist to catch a just-bound or shadowed proxy (#764, #5004). | ||
| process.env.OCX_PROBE_TIMEOUT_MS = "1000"; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=raise-default-only"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(1000); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(1500); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(1500); | ||
| }); | ||
|
|
||
| test("a malformed override falls back to the defaults at module load", async () => { | ||
| process.env.OCX_PROBE_TIMEOUT_MS = "not-a-number"; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=malformed"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(750); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(1500); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(1500); | ||
| }); | ||
|
|
||
| test("a value beyond the signed-32-bit ceiling is ignored", async () => { | ||
| // AbortSignal.timeout() only accepts that range; an out-of-range delay throws | ||
| // in Bun and the probe path would misread it as a dead proxy. | ||
| process.env.OCX_PROBE_TIMEOUT_MS = "2147483648"; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=overflow"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(750); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(1500); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(1500); | ||
| }); | ||
|
|
||
| test("the ceiling itself is accepted", async () => { | ||
| process.env.OCX_PROBE_TIMEOUT_MS = "2147483647"; | ||
| const mod = await import("../../src/server/proxy-liveness.ts?wiring=ceiling"); | ||
| expect(mod.DEFAULT_PROBE_TIMEOUT_MS).toBe(2_147_483_647); | ||
| expect(mod.SERVICE_STOP_LIVENESS.timeoutMs).toBe(2_147_483_647); | ||
| expect(mod.START_OWNERSHIP_LIVENESS.timeoutMs).toBe(2_147_483_647); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 27836
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 23104
Restore
OCX_PROBE_TIMEOUT_MSafter each test.These tests mutate process-global state without cleanup. The final test leaves
OCX_PROBE_TIMEOUT_MSset to"not-a-number". A later same-process import can read that value at module load and use the malformed-override fallback. Save the previous value and restore it infinallyafter each import and assertion, preserving whether the variable was originally unset.🤖 Prompt for AI Agents