Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(llm-proxy): measure the stalled-loop block from the gate's own start

Alfredo Lopezaf7acf2d8779
diff --git a/codex-llm-proxy/test/requestLimits.test.ts b/codex-llm-proxy/test/requestLimits.test.ts
index 597d0d2f2..5a7378bff 100644
--- a/codex-llm-proxy/test/requestLimits.test.ts
+++ b/codex-llm-proxy/test/requestLimits.test.ts
@@ -258,8 +258,11 @@ describe('StreamGate', () => {
it('refuses a waiter whose poll runs after the bound because the event loop stalled', async () => {
const gate = new StreamGate(1, 1, 500)
const release = await gate.acquire()
- const queuedAt = performance.now()
const { state, waiter } = track(gate)
+ // Read after acquire() has recorded its own start, so the block below
+ // measures at least as long as the gate does. Read before it, a runner
+ // pause between the two reads would come out of the 30 ms margin.
+ const queuedAt = performance.now()
await new Promise(resolve => setTimeout(resolve, 20))
// Witness: the poll has run and found the slot taken. The 500 ms bound
// leaves 25x the 20 ms wait, so a paused runner does not fire the deadline
diff --git a/grok-llm-proxy/test/requestLimits.test.ts b/grok-llm-proxy/test/requestLimits.test.ts
index 0296b323f..bd271b6e4 100644
--- a/grok-llm-proxy/test/requestLimits.test.ts
+++ b/grok-llm-proxy/test/requestLimits.test.ts
@@ -249,8 +249,11 @@ describe('StreamGate', () => {
it('refuses a waiter whose poll runs after the bound because the event loop stalled', async () => {
const gate = new StreamGate(1, 1, 500)
const release = await gate.acquire()
- const queuedAt = performance.now()
const { state, waiter } = track(gate)
+ // Read after acquire() has recorded its own start, so the block below
+ // measures at least as long as the gate does. Read before it, a runner
+ // pause between the two reads would come out of the 30 ms margin.
+ const queuedAt = performance.now()
await new Promise(resolve => setTimeout(resolve, 20))
// Witness: the poll has run and found the slot taken. The 500 ms bound
// leaves 25x the 20 ms wait, so a paused runner does not fire the deadline