Repository navigation
fix(ai-gemini): keep httpOptions.timeout in geminiImage when a signal is passed - #2313
pcbeingused33 wants to merge 1 commit into
Conversation
… is passed The Interactions client only applies httpOptions.timeout when the request has no signal. The image adapter passed the caller's abortSignal as is, so the configured timeout was dropped. Combine both with withHttpTimeout, as the text and video adapters already do.
🦋 Changeset detectedLatest commit: 29570f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Thanks for the PR, @pcbeingused33! 🙌 @jherr will take a look. Automated pre-review checks
Automated triage — a human review follows. |
🎯 Changes
geminiImage()dropped the configuredhttpOptions.timeoutwhenever the caller passed anabortSignal. The@google/genaiInteractions client applieshttpOptions.timeoutonly when the request has no signal of its own (documented onwithHttpTimeoutinutils/client.ts). The text and video adapters already handle this withwithHttpTimeout(#1975), but the image adapter still passedoptions.abortSignalstraight toclient.interactions.create. So an image request with a caller signal could hang past the timeout.Root cause:
generateImages()inpackages/ai-gemini/src/adapters/image.tsused{ signal: options.abortSignal }without merging in the timeout.Fix: store
config.httpOptions?.timeoutin the constructor and passwithHttpTimeout(options.abortSignal, this.timeoutMs)as the signal, the same wayvideo.tsdoes it. Without a timeout or without a caller signal, the request is unchanged.Tests: two cases in
tests/abort-signal-wire.test.ts, next to the existing text and video ones:image: the timeout abortsfails onmain(the request is never aborted) and passes with this change.image: the caller still abortschecks that the caller signal still reaches the request.No E2E case was added: the aimock setup answers right away, so it cannot show a client-side timeout. The unit tests stub the wire fetch the same way the existing timeout tests do.
Docs: not updated; this makes the image adapter follow the documented
httpOptions.timeoutbehaviour.Test plan (package-level checks; the full
pnpm run test:prwas not run):pnpm --filter @tanstack/ai-gemini exec vitest run(532 passed; the new timeout test fails onmain)tscforpackages/ai-gemini,oxlint src --type-aware,oxfmt --checkon the changed files✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
This change was prepared with the assistance of an AI coding assistant.
Summary by CodeRabbit