Skip to content

Commit 839cbbc

Browse files
test(opencode-go): parameterize the pending-request deadline over both request formats
Review follow-up: run the never-settling SDK request case against Chat Completions and Responses, asserting AbortError, bounded elapsed time and an aborted request signal. opencode-go.spec 183 passed.
1 parent 7a352ab commit 839cbbc

1 file changed

Lines changed: 27 additions & 17 deletions

File tree

‎src/api/providers/__tests__/opencode-go.spec.ts‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,24 +2979,34 @@ describe("OpencodeGoHandler", () => {
29792979
expect(createMock).not.toHaveBeenCalled()
29802980
})
29812981

2982-
it("rejects at the deadline even while the SDK retry delay keeps the request pending", async () => {
2983-
// The SDK's internal retry backoff is not covered by the request signal; without the
2984-
// rejectOnAbort race this promise would never settle and the test would time out.
2985-
let requestSignal: AbortSignal | undefined
2986-
mockCreate.mockImplementation(
2987-
(_params: unknown, options?: { signal?: AbortSignal }) =>
2988-
new Promise((_resolve) => {
2989-
requestSignal = options?.signal
2990-
}),
2991-
)
2992-
const handler = new OpencodeGoHandler(mockOptions)
2982+
it.each([
2983+
["Chat Completions", () => new OpencodeGoHandler(mockOptions), mockCreate],
2984+
[
2985+
"Responses",
2986+
() => new OpencodeGoHandler({ ...mockOptions, opencodeGoModelId: "gpt-5.6-luna" }),
2987+
mockResponsesCreate,
2988+
],
2989+
])(
2990+
"rejects at the deadline even while the SDK retry delay keeps the %s request pending",
2991+
async (_label, makeHandler, createMock) => {
2992+
// The SDK's internal retry backoff is not covered by the request signal; without the
2993+
// rejectOnAbort race this promise would never settle and the test would time out.
2994+
let requestSignal: AbortSignal | undefined
2995+
createMock.mockImplementation(
2996+
(_params: unknown, options?: { signal?: AbortSignal }) =>
2997+
new Promise((_resolve) => {
2998+
requestSignal = options?.signal
2999+
}),
3000+
)
3001+
const handler = makeHandler() as OpencodeGoHandler
29933002

2994-
const started = Date.now()
2995-
const error = await handler.completePrompt("ping", { timeoutMs: 30 }).catch((caught: unknown) => caught)
3003+
const started = Date.now()
3004+
const error = await handler.completePrompt("ping", { timeoutMs: 30 }).catch((caught: unknown) => caught)
29963005

2997-
expect(error).toMatchObject({ name: "AbortError" })
2998-
expect(Date.now() - started).toBeLessThan(1_000)
2999-
expect(requestSignal?.aborted).toBe(true)
3000-
})
3006+
expect(error).toMatchObject({ name: "AbortError" })
3007+
expect(Date.now() - started).toBeLessThan(1_000)
3008+
expect(requestSignal?.aborted).toBe(true)
3009+
},
3010+
)
30013011
})
30023012
})

0 commit comments

Comments
 (0)