LibreChat/client
Marco Beretta 4fb238d5fe 🔌 refactor: Drive useSSE Through the ChatTransport (#16336)
* refactor: drive useSSE through the ChatTransport

Move the sse.js connection, frame parsing, the named attachment and
error events, the 401 refresh-and-retry and the cancel-on-close signal
into client/src/hooks/SSE/transport. normalizeFrame tags each message
frame by the keys the hooks already checked, in the same order, and
createSSETransport emits the resulting ChatEvent union. useSSE now
switches on event.type and calls the same handlers with the same
arguments; its signature is unchanged.

A frame that is not JSON is now logged and skipped. Previously the
parse error escaped the listener and dropped every frame behind it in
the same chunk.

createdHandler never read its first argument, so it is typed as the
created frame it actually receives instead of TResData.

* fix: keep the stream closed when a 401 refresh settles after abort

A refresh that resolved after the caller aborted called sse.stream()
again, reopening the request with the unmounted consumer's handlers; a
refresh that failed after abort dispatched the error path. Both now
return once the signal is aborted.

* fix: refresh the token at most once per stream

A retried connection that drew another 401 refreshed and reconnected
again with no bound, so a server rejecting the refreshed token looped.
The second 401 now reaches the error path.

* refactor: consume the widened content frame type

The content handler never read userMessageId, which Assistants content
frames do not send, so it now takes ChatContentFrame.

* refactor: bridge the wider step and attachment frames to their handlers

The handlers accept narrower payload types than the wire frames now
admit. useSSE narrows at the call, where these frames already reached
the handlers unchanged before the transport existed.

* fix: cancel a turn aborted while its 401 refresh is pending

sse.js marks the connection closed on the 401, so an abort during the
refresh skipped the cancel path and nothing reset the submitting state.
The stream now counts as open until the refresh settles.

(cherry picked from commit a3541da463)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16336
2026-10-01 03:46:17 +00:00
..
public 🧩 feat: MCP Apps support (#13831) 2026-10-01 03:46:16 +00:00
src 🔌 refactor: Drive useSSE Through the ChatTransport (#16336) 2026-10-01 03:46:17 +00:00
sw
test 🎨 feat: Theme-Adaptive SVG Support for Custom MCP and Group Icons (#13817) 2026-09-04 10:49:43 -04:00
babel.config.cjs
check_updates.sh
index.html 🗄️ fix: Fall Back to In-Memory Storage When Web Storage Is Denied (#16431) 2026-09-28 12:28:52 +02:00
jest.config.cjs 🧩 feat: MCP Apps support (#13831) 2026-10-01 03:46:16 +00:00
jest.resolver.cjs
nginx.conf
package.json 🧩 feat: MCP Apps support (#13831) 2026-10-01 03:46:16 +00:00
postcss.config.cjs 🌊 refactor: Upgrade the Client to Tailwind v4 (#15996) 2026-10-01 03:46:16 +00:00
tailwind.config.cjs 🎨 feat: Check Color Tokens and Class Existence (#16041) 2026-10-01 03:46:16 +00:00
tsconfig.json
vite.config.ts 🖼️ fix: Precache PWA Icons and Let Them Refresh (#15654) 2026-09-06 11:32:09 -04:00