mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7441] [MERGED] fix(server): compress API JSON synchronously so early sends keep their body #7734
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#7734
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/7441
Author: @SpicyMarinara
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/compress-json-sync📝 Commits (1)
40e1e85fix(server): compress API JSON synchronously so early sends keep their body📊 Changes
3 files changed (+26 additions, -8 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/middleware/compress-json.ts(+16 -8)📝
scripts/regressions/compress-json.regression.ts(+9 -0)📄 Description
Linked issue
Closes #7440
Why this change
63006ab28, Windows 11) says Game mode can't create a new game with any connection or setup. The log showsFST_ERR_REP_ALREADY_SENTonPOST /api/game/setup.brorgzip, which every browser does. WithoutAccept-Encodingit came back as the full JSON. The server logged the reporter's exact three lines.compressJsonHook(445512d4b, merged with #7312) awaits Brotli/gzip. An async handler that sends withoutreturn replyresolves during that wait, so Fastify sends a second, empty reply that wins the race. This affects Game setup,/game/setup/apply-jsonand other handlers with the same shape. Tests missed it becauseapp.inject()replies are never compressed.returnto three sends) doesn't apply: those sends are already followed byreturn;.What changed
compressJsonHookis synchronous and callback-style (brotliCompressSync/gzipSync), with the same quality settings. That restores the timing from before445512d4bfor every route, not just Game setup. The cost is about 1–6 ms of event-loop time per MB of JSON, similar to theJSON.stringifyalready done for the same body.compress-jsonnow covers an async handler that sends without returning. It fails on staging's hook ("a handler that sends without returning reply gets its body") and passes with the fix.return replyto the handlers. With the hook synchronous it's no longer needed, and the hook fix covers every call site.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent:
pnpm check, plus thecompress-json,capability-prompt-previewandpromptregressions (all pass). The real-HTTP reproduction (mock provider, browserAccept-Encoding, streaming and non-streaming, slow replies,<think>blocks) passed with this fix applied.Manual verification notes
content-encoding: br).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG
[Unreleased]has an entry. No user docs change.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.