test(openai): clear roundtrip timeout on early failure

This commit is contained in:
Vincent Koc
2026-07-30 23:45:37 +08:00
parent 786d40d607
commit 5f0c49b65d
+10 -7
View File
@@ -502,19 +502,22 @@ async function smokeOpenAIAudioRoundtrip(apiKey: string, cycleCount: number): Pr
},
});
bridgeRef.current = bridge;
const boundedRoundtrip = withTimeout({
label: `OpenAI audio roundtrip cycle ${cycle}`,
timeoutMs: OPENAI_AUDIO_ROUNDTRIP_TIMEOUT_MS,
run: () => roundtrip,
});
// Observe failures immediately; the same promise is awaited after input streaming completes.
void boundedRoundtrip.catch(() => undefined);
let chunksSent = 0;
try {
await bridge.connect();
const boundedRoundtrip = withTimeout({
label: `OpenAI audio roundtrip cycle ${cycle}`,
timeoutMs: OPENAI_AUDIO_ROUNDTRIP_TIMEOUT_MS,
run: () => roundtrip,
});
// Observe failures immediately; the same promise is awaited after input streaming completes.
void boundedRoundtrip.catch(() => undefined);
chunksSent = await sendPcmAudioInChunks(bridge, inputAudio);
await boundedRoundtrip;
} catch (error) {
rejectRoundtrip?.(error instanceof Error ? error : new Error(String(error)));
throw error;
} finally {
closed = true;
bridge.close();