Skip to content

Commit 9041eb1

Browse files
committed
Address review: pin no premature abort before early termination
The early-termination test only observed the request-local signal after stream.return(), so a premature abort (one landing while the consumer is still iterating) would also pass. The test now captures the SDK request options after the first chunk and asserts the request-local signal is still live (aborted === false) before the early return, retaining the post-return aborted assertion. Negative control: aborting the request-local controller right after the SDK create call fails exactly this test (isolated run: the new false assertion reddens). Verification at this head: 27/27 green in lm-studio.spec.ts; tsc --noEmit 0 errors; eslint --max-warnings=0 clean with suppression counts unchanged; prettier clean.
1 parent f621443 commit 9041eb1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/api/providers/__tests__/lm-studio.spec.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,14 @@ describe("LmStudioHandler abort wiring", () => {
467467
const first = await stream.next()
468468
expect(first.value).toEqual({ type: "text", text: "first" })
469469

470+
const opts = create.mock.calls[0][1]
471+
// No premature abort: while the consumer is still iterating, the
472+
// request-local signal must still be live.
473+
expect(opts?.signal.aborted).toBe(false)
474+
470475
await stream.return(undefined) // consumer stops early; finally must cancel the request
471476

472-
const opts = create.mock.calls[0][1]
473-
expect(opts?.signal.aborted).toBe(true) // the request-local SDK signal is aborted
477+
expect(opts.signal.aborted).toBe(true) // the request-local SDK signal is aborted
474478
const listener = addSpy.mock.calls.find(([type]) => type === "abort")?.[1]
475479
expect(typeof listener).toBe("function")
476480
expect(removeSpy).toHaveBeenCalledWith("abort", listener) // the bridge is detached by reference

0 commit comments

Comments
 (0)