mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5138] [Feature]: Consolidate generation SSE emission behind one canonical owner #2838
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#2838
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?
Originally created by @Xelvanis on GitHub (Aug 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5138
Originally assigned to: @SpicyMarinara on GitHub.
What problem does this solve?
Generation-family SSE data frames are currently emitted from several places: the canonical
sendSseEventhelper inpackages/server/src/routes/generate/sse.ts, an exact alias (trySendSseEvent), and a handful of call sites that serializedata: ${JSON.stringify(...)}payloads directly ontoreply.raw. The main/generateand/retry-agentshandlers additionally monkey-patchreply.raw.writeper request to duplicate the closed-socket guard.This duplication means socket-lifecycle safety (destroyed/ended/finished checks plus write/serialization failure containment) has multiple apparent owners, native
writeidentity is patched per-request, and every future event site has to remember the full framing/guard recipe or silently reintroduce unsafe writes.Proposed solution
Give generation-family SSE data framing and closed-socket write safety one canonical owner:
sendSseEvent, including the newerdelayed,typing, and inventorygame_state_patchevents.trySendSseEventalias and update its callers.reply.raw.writeinterception and the now-obsolete route-local stream-closure catch layers.Alternatives considered
Additional context
Follow-up to the behavior-preserving cleanup series in #5069 / #5070, applying the same one-commit-per-cleanup discipline. The change is purely internal: no event shapes, ordering, or disconnect behavior change. Reviewed with independent multi-lens review (correctness, ownership/structure, simplification, risk) plus cold triage; transport-level and live disconnect validation back the behavior-preservation claim.
Template check