Skip to content

Commit d7eae0f

Browse files
test(relay): timeout test waits until the request reaches the environment
Hashing the budget key made the step before the upstream call asynchronous, so advancing the test clock early never fired the timeout. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 68b7300 commit d7eae0f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎infra/relay/src/hooks/HookForwarder.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from "@effect/vitest";
2+
import * as Deferred from "effect/Deferred";
23
import * as Duration from "effect/Duration";
34
import * as Effect from "effect/Effect";
45
import * as Fiber from "effect/Fiber";
@@ -315,10 +316,17 @@ describe("HookForwarder", () => {
315316

316317
it.effect("maps an upstream timeout to 504", () =>
317318
Effect.gen(function* () {
318-
const harness = makeHarness({ execute: () => Effect.never });
319+
// Advance the clock only once the request is waiting on the environment;
320+
// hashing the budget key before that step is asynchronous.
321+
const reachedUpstream = yield* Deferred.make<void>();
322+
const harness = makeHarness({
323+
execute: () =>
324+
Deferred.succeed(reachedUpstream, undefined).pipe(Effect.andThen(Effect.never)),
325+
});
319326
const fiber = yield* harness
320327
.send(new Request(hookUrl(), { method: "POST", body: "{}" }))
321328
.pipe(Effect.forkChild);
329+
yield* Deferred.await(reachedUpstream);
322330
yield* TestClock.adjust(Duration.millis(HookForwarder.RELAY_HOOK_UPSTREAM_TIMEOUT_MS));
323331
const response = yield* Fiber.join(fiber);
324332
expect(response.status).toBe(504);

0 commit comments

Comments
 (0)