LibreChat/api/server
Marco Beretta 698ee25fea
🧯 fix: Close Abandoned Download and Speech Streams and Cap Speech Input (#17270)
* fix: Contain Download and Speech Stream Failures and Cap Speech Input

The code output download piped the Code API stream with .pipe, which adds no
error listener, so a body that failed mid-stream (a bad gzip body, a reset)
became an uncaught exception and the process exited. pipeToResponse uses
stream.pipeline, ending the response and destroying the upstream when the
client leaves.

Text-to-speech piped provider streams the same way and waited only for
'end', so a provider error was uncaught and a client disconnect left the
chunk loop waiting. pipeSegment resolves on end and rejects on an error or
a disconnect, which ends the loop.

A speech request had no length cap, so one request could fan out into
thousands of serial paid provider calls. speech.tts.maxInputChars bounds it
(default 20,000 characters).

* docs: Document the Speech Input Cap in the Example Config

* fix: Reject a Speech Segment When the Client Already Left

* fix: Tear Down Both Ends of a Failed Speech Segment and Cap Streamed Speech

A failed provider segment now destroys the response as well as the source,
so a half-written answer cannot hang the client, and a response-side error
rejects the segment instead of going unhandled. Automatic playback reads a
message only up to speech.tts.maxInputChars, so long messages cannot fan
out past the cap either.

The download scenario now checks the behavior .pipe lacked: leaving a code
download closes the upstream connection right away.

* fix: Keep a Late Response Write Error From Going Unhandled

* test: Key Slow Code Downloads by File and Send a Browser User Agent

* fix: Read Speech Up to the Cap Instead of Refusing It

Manual speech now synthesizes the text up to speech.tts.maxInputChars, the
same as automatic playback, through capSpeechInput, so the CJS service only
passes the capped text along and the request keeps its existing error
contract. A streamed message that reaches the cap exactly now finishes, and
a segment that fails before any audio went out leaves the response open for
the caller's HTTP error.

* fix: Count Only Text Against the Speech Cap
2026-10-19 22:20:40 +02:00
..
controllers 🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261) 2026-10-19 22:13:31 +02:00
middleware 🔒 fix: Restrict Stop to the Generation's Owner and Contain S3 Ingest Stream Errors (#17256) 2026-10-19 15:56:03 +02:00
routes 🧯 fix: Close Abandoned Download and Speech Streams and Cap Speech Input (#17270) 2026-10-19 22:20:40 +02:00
services 🧯 fix: Close Abandoned Download and Speech Streams and Cap Speech Input (#17270) 2026-10-19 22:20:40 +02:00
utils 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
cleanup.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
csp.spec.js 🔌 fix: Close Leaked HTTP Server in Server Specs (#15821) 2026-09-10 15:17:06 -04:00
experimental.js 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
experimental.spec.js ⏳ fix: Expire Dead-Lettered Trigger Deliveries and Clean Up Orphaned Image Uploads (#17049) 2026-10-14 17:58:56 +02:00
index.js 🩺 fix: Report Not Ready on /readyz While Redis Is Disconnected (#17232) 2026-10-18 21:40:00 +02:00
index.metrics.spec.js 🔌 fix: Close Leaked HTTP Server in Server Specs (#15821) 2026-09-10 15:17:06 -04:00
index.spec.js 🔭 feat: Recover Stale Chunks Without the Error Page and Ship Client Logs to RUM (#16701) 2026-10-03 23:17:56 -04:00
socialLogins.js 🔁 feat: Retry OpenID Discovery After Startup Failures (#15899) 2026-09-13 23:16:26 -04:00
socialLogins.spec.js 🔁 feat: Retry OpenID Discovery After Startup Failures (#15899) 2026-09-13 23:16:26 -04:00
telemetry.js 🪵 feat: Add OpenTelemetry Logs Pipeline via Winston Bridge (#15565) 2026-09-03 21:16:09 -04:00
telemetry.spec.js 🪵 feat: Add OpenTelemetry Logs Pipeline via Winston Bridge (#15565) 2026-09-03 21:16:09 -04:00