project-nomad/admin/app
chriscrosstalk 4b21ea6c40 fix(API): skip compression for Server-Sent Events (#798)
* fix(stream): skip compression for Server-Sent Events

The global compression middleware (added in v1.31.0-rc.2) buffers
response writes to determine encoding, which collapses per-token
streaming into a single block delivered after generation completes.
This broke the AI chat streaming UX from v1.31.0-rc.2 onward — text
no longer appears progressively as the model generates it, only at
the end.

Adds a filter to compression() that returns false when the response
Content-Type is text/event-stream. Other responses still go through
the default compression filter (compressible types are still
compressed; e.g. text/html via Brotli).

Reproduced on NOMAD3 v1.31.1: before fix, all SSE chunks for a 1B
model arrive within 10ms of each other after the model finishes.
After fix, tokens arrive at ~150ms intervals as they're generated
on a 12B model, with no Content-Encoding header on the SSE response.

Verified on the same host that /home still returns
Content-Encoding: br for HTML responses.

Closes #781. Reported and bisected by @toasterking
(works in v1.31.0-rc.1, broken from v1.31.0-rc.2 onward).

* fix(stream): use any for filter params to match existing as-any pattern

The compression library types its filter as (req: Request, res: Response)
expecting Express types, but AdonisJS passes raw IncomingMessage/ServerResponse
which is why the surrounding middleware uses `as any` casts at the call site.
The IncomingMessage/ServerResponse types I added are runtime-correct but
fail tsc against the library's declared types.

Drop the typed import in favor of `any` parameters, which matches how the
existing `compress(request.request as any, response.response as any, ...)`
call resolves the same mismatch.
2026-05-20 10:16:00 -07:00
..
controllers fix(AI): stop local nomad_ollama container when remote Ollama is configured (#744) 2026-04-21 14:26:28 -07:00
exceptions fix(Docs): documentation renderer fixes 2025-12-23 16:00:33 -08:00
jobs fix(AI): allow cancelling in-progress model downloads and ensure consistent progress UI (#701) 2026-04-21 14:26:28 -07:00
middleware fix(API): skip compression for Server-Sent Events (#798) 2026-05-20 10:16:00 -07:00
models feat(maps): add scale bar and location markers (#636) 2026-04-03 14:26:50 -07:00
services feat(content-manager): add sortable file size column (#698) 2026-05-20 10:16:00 -07:00
utils fix(Downloads): remove duplicate err listnr and improv Range req stability 2026-04-21 14:26:28 -07:00
validators fix: block IPv4-mapped IPv6 and IPv6 all-zeros in SSRF check (#520) 2026-04-03 14:26:50 -07:00