Skip to content

Commit 7cc45e3

Browse files
committed
test(mistral): attach an abort listener so the first-cause test can observe it
What: the "keeps TimeoutError when the timeout fires before a later caller abort" case now attaches an abort listener to the merged request signal from its completePrompt mock, the way a real fetch does. Why: on Node 24, AbortSignal.any() is a lazy composite. It materializes the first-cause reason at abort time only when something is listening; with no listener it re-reads the live source signals when .reason is first accessed, so a later caller abort overwrote the earlier timeout reason and the handler correctly reclassified the failure as AbortError. The test, not the product code, was wrong: it asserted a reason the runtime never computed. The pinned Node 22.23.4 behaves the same way, so this is not a version drift. Impact: test-only. mistral.spec.ts goes from 49/50 to 50/50 on this base, and the product classification logic in src/api/providers/mistral.ts is unchanged.
1 parent 159c42e commit 7cc45e3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/api/providers/__tests__/mistral.spec.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,13 @@ describe("MistralHandler", () => {
922922
// the request. Both signals are already aborted when completePrompt's catch runs,
923923
// so the test really pins the first-cause classification.
924924
mockComplete.mockImplementation(
925-
() =>
925+
(_options: unknown, requestOptions?: { fetchOptions?: { signal?: AbortSignal } }) =>
926926
new Promise<never>((_resolve, reject) => {
927+
// Attach a listener the way a real fetch does: Node's composite
928+
// AbortSignal.any materializes its first-cause reason at abort time
929+
// only when something is listening, and reads the live source
930+
// signals otherwise.
931+
requestOptions?.fetchOptions?.signal?.addEventListener("abort", () => {}, { once: true })
927932
rejectRequest = reject
928933
}),
929934
)

0 commit comments

Comments
 (0)