mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5139] [MERGED] refactor: consolidate SSE emission ownership #6648
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#6648
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/5139
Author: @Xelvanis
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @SpicyMarinara
Base:
staging← Head:cleanup/sse-emission-ownership-current📝 Commits (3)
98b85b3refactor: consolidate SSE emission ownership3df9f5frefactor: use shared SSE writability guard in Professor Mari route2ae6c51Merge branch 'staging' into cleanup/sse-emission-ownership-current📊 Changes
7 files changed (+180 additions, -278 deletions)
View changed files
📝
packages/server/src/routes/generate.routes.ts(+161 -245)📝
packages/server/src/routes/generate/fallback-notification.ts(+2 -2)📝
packages/server/src/routes/generate/retry-agents-route.ts(+2 -13)📝
packages/server/src/routes/generate/sse.ts(+0 -4)📝
packages/server/src/routes/professor-mari-workspace.routes.ts(+4 -4)📝
packages/server/src/services/generation/turn-game-command-runtime.ts(+2 -1)📝
packages/server/src/services/turn-games/turn-game-bot-runner.service.ts(+9 -9)📄 Description
Linked issue
Closes #5138
Why this change
Generation-family SSE data frames were emitted from several places: the canonical
sendSseEventhelper inpackages/server/src/routes/generate/sse.ts, an exact alias (trySendSseEvent), and call sites that serializeddata: ${JSON.stringify(...)}payloads directly ontoreply.raw, while the main/generateand/retry-agentshandlers monkey-patchedreply.raw.writeper request to duplicate the closed-socket guard. Socket-lifecycle safety therefore had multiple apparent owners, nativewriteidentity was patched per-request, and every future event site had to remember the full framing/guard recipe or silently reintroduce unsafe writes.What changed
Behavior-preserving consolidation, seven files, net −98 lines:
sendSseEvent, including the newerdelayed,typing, and inventorygame_state_patchevents.trySendSseEventalias and update its callers.reply.raw.writeinterception and two obsolete character-tracker stream-closure catch layers.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkexited 0 on a clean worktree at the current head3df9f5fb8(impeccable context, localization, workspace lint, full client+server builds).scripts/regressions/manual-agent-retry-resolution.regression.tspassed (1/1).try/catchreproduced an escapingwrite EPIPE(negative efficacy), then the source was restored byte-identically.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable — no UI change; wire behavior is byte-identical.
Summary by CodeRabbit
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.