Conversation
Replace unbounded `arrayBuffer()`/`blob()` calls in `download()` and `downloadBlob()` with streaming reads that enforce a 2 GiB default size limit. Add `abortSignal` passthrough from callers (`transcribe`, `generateVideo`) to `fetch()`. Add `maxDownloadSize` option to `transcribe()` and `experimental_generateVideo()` for configuring the limit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update API reference docs and fix JSDoc/changeset to reflect actual 1 GiB default (changed from 2 GiB during review). Update test Content-Length values to match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace `maxDownloadSize` parameter with a configurable `download`
function in `transcribe()` and `experimental_generateVideo()`. Add
`createDownload({ maxBytes })` factory exported from `ai` so users
can create download functions with custom size limits.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
5 tasks
Collaborator
|
why is the download blob function in |
lgrammel
reviewed
Feb 12, 2026
| export { convertToFormData } from './convert-to-form-data'; | ||
| export { downloadBlob } from './download-blob'; | ||
| export { DownloadError } from './download-error'; | ||
| export { |
Collaborator
There was a problem hiding this comment.
a) could this be part of the ai pkg instead
b) the difference between file and function name is strange
lgrammel
approved these changes
Feb 12, 2026
Collaborator
Author
it's also used by I'll look into refactoring but not yet sure if it's worth it.
Will fix, thanks |
Collaborator
Author
|
I tried some refactoring, but it would lead to a circular dependency or code duplication to move |
gr2m
added a commit
that referenced
this pull request
Feb 12, 2026
- Replace unbounded `arrayBuffer()`/`blob()` calls in `download()` and
`downloadBlob()` with streaming reads that enforce a **2 GiB default
size limit**
- Add `abortSignal` passthrough from callers (`transcribe`,
`generateVideo`) to `fetch()`
- Check `Content-Length` header for early rejection before reading body
- Track bytes incrementally via `ReadableStream.getReader()`, abort with
`DownloadError` when limit exceeded
- Expose configurable `download` parameter on `transcribe()` and
`experimental_generateVideo()` (instead of adding a new
`maxDownloadSize` argument) — keeps download config separate from API
function signatures
- Export `createDownload({ maxBytes })` factory from `ai` for custom
size limits
closes #9481 / addresses
#9481 (comment)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
This was referenced Feb 12, 2026
gr2m
added a commit
that referenced
this pull request
Feb 12, 2026
## Summary - Backport of #12445 to `release-v5.0` - Adds size-limited download via `readResponseWithSizeLimit` to prevent unbounded memory consumption (DoS) - Adds `maxBytes` and `abortSignal` parameters to download functions - Skipped generate-video and download-blob changes (files don't exist on v5.0) ## Test plan - [x] Test changes against local POC Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
arrayBuffer()/blob()calls indownload()anddownloadBlob()with streaming reads that enforce a 2 GiB default size limitabortSignalpassthrough from callers (transcribe,generateVideo) tofetch()Content-Lengthheader for early rejection before reading bodyReadableStream.getReader(), abort withDownloadErrorwhen limit exceededdownloadparameter ontranscribe()andexperimental_generateVideo()(instead of adding a newmaxDownloadSizeargument) — keeps download config separate from API function signaturescreateDownload({ maxBytes })factory fromaifor custom size limitscloses #9481 / addresses #9481 (comment)