mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2401] [MERGED] Cap TTS provider response while streaming to prevent OOM #5581
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5581
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2401
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/tts-stream-cap📝 Commits (3)
dc585feCap TTS provider response while streaming to prevent OOM56073c5Classify an oversized TTS error-status body as a provider error3ccbde4Drop the TTS error-classification harden and keep only the streaming cap📊 Changes
1 file changed (+29 additions, -7 deletions)
View changed files
📝
src-tauri/src/commands/storage/integrations/tts.rs(+29 -7)📄 Description
Linked issue
Closes #2324
Why this change
speak()fully buffered the provider response into memory viaresponse.bytes().awaitand only enforced the 20MB cap afterward. A hostile or misconfigured endpoint could stream a multi-GB body (with the request timeout up to 30 min) and OOM the process before the cap ever ran.What changed
src-tauri/src/commands/storage/integrations/tts.rs: replacedbytes().awaitwith a newread_capped_audio_byteshelper that does acontent_length()pre-check againstMAX_TTS_AUDIO_BYTESand then streams via a.chunk()loop with a saturating running counter, aborting the moment the cap is exceeded. Mirrors the in-reporead_limited_webhook_textpattern incustom_tools.rs. The post-buffer size check is removed (now enforced during streaming); the sameinvalid_input"TTS audio response is too large" message is preserved on both reject paths.Refactor impact
Primary owner: Rust storage (integrations)
Impact areas reviewed:
src-tauri/src/commands/storage/integrations/tts.rs(speak, newread_capped_audio_bytes)Boundary notes:
Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine tts— 13 passed, including local-only tests for thecontent_lengthpre-check (declared-41MB body rejected before download) and the streamed-overflow abort (no Content-Length, >20MB stream aborts); happy path unchanged.cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings— clean.Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.