Skip to content

Commit 718894e

Browse files
committed
test(oauth): bound each callback delivery attempt by the remaining deadline
A listener that accepts the connection but never answers would hold the retry loop past its deadline, leaving the flow unabortable.
1 parent 503c8d5 commit 718894e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/oauth/test/openai-codex-oauth.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,13 @@ describe('startOpenAICodexCallbackServer', () => {
357357
// loopback listener gets a pass, and it says so.
358358
const deadline = Date.now() + 5_000;
359359
let delivered = false;
360-
while (!delivered && Date.now() < deadline) {
360+
while (!delivered) {
361+
const remaining = deadline - Date.now();
362+
if (remaining <= 0) break;
361363
try {
362-
await fetch(url);
364+
// Cap each attempt too: a listener that accepts but never answers
365+
// would otherwise hold this past the deadline.
366+
await fetch(url, { signal: AbortSignal.timeout(remaining) });
363367
delivered = true;
364368
} catch {
365369
await new Promise((resolve) => setTimeout(resolve, 50));

0 commit comments

Comments
 (0)