fix(backend): raise compress threshold to fix empty zstd /api/health body - #685
Merged
Conversation
…y-body bug The shipped EE backend (Node 24.15-alpine, @fastify/compress 8.3.1) deterministically returns an empty body with `content-encoding: zstd` and `content-length: 0` for `/api/health` (1042-byte JSON) when the browser sends `Accept-Encoding: gzip, br, zstd`. Larger payloads on the same plugin (e.g. `/api/pages/:id` at 1614 bytes) compress correctly. User-visible symptom: the Settings → Diagnostics page falls back to "Edition: Community (CE)" and "Backend commit: …" because the `useBackendBuildInfo()` `useQuery` parses `await response.json()` from an empty body — the actual version/commit/builtAt metadata never reaches the UI. Reproduces only against the deployed container, not against `@fastify/compress 8.3.1` in isolation on Node 26 with the same payload shape — likely an interaction with the container's Node 24 zlib zstd encoder or the EE build pipeline. Investigation hit diminishing returns; the workaround is to push the threshold above the bug-prone size range. Sub-4KB payloads barely benefit from compression anyway once you net out the encoding-header overhead, so the bandwidth cost is negligible. Two regression tests in `app.test.ts` pin the behaviour: a ~1KB synthetic route must not be compressed; a ~5KB synthetic route must be (so the plugin stays wired up rather than effectively disabled). Once this lands on `main` (via the usual release branch), the EE backend needs to be rebuilt for the Diagnostics page to start showing real backend metadata. The CE fallback `/api/health` route is unaffected since CE doesn't compose with `@fastify/compress` in the same way at runtime (community mode runs the same code, but the production EE container is where the bug was observed). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
/api/healthwas returning an empty body withcontent-encoding: zstdandcontent-length: 0to the browser in the deployed EE backend container — Settings → Diagnostics consequently fell back to "Edition: Community (CE)" and "Backend commit: …" becauseawait response.json()parsed an empty body./api/pages/:idat 1614 bytes) compressed fine. The bug is deterministic on the deployed container but does not reproduce against@fastify/compress 8.3.1in isolation on Node 26 with the same payload shape — almost certainly an interaction with the container's Node 24 zstd encoder or the EE build pipeline. Investigation hit diminishing returns.compresswith{ threshold: 4096 }. Payloads in the bug-prone size range pass through uncompressed; payloads where compression actually saves meaningful bandwidth still get compressed.Repro before the fix
After the fix the same request returns the full 1042-byte JSON with no
content-encodingheader.Test plan
app.test.ts:content-encoding, body intactFollow-up
The EE backend image needs to be rebuilt for this fix to take effect in the running stack. Tracking the underlying
@fastify/compress/ Node 24 zstd interaction in a separate issue.🤖 Generated with Claude Code