[PR #454] [MERGED] Fix spurious abort on normal generation completion #4624

Closed
opened 2026-10-22 04:09:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/454
Author: @Xelvanis
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @SpicyMarinara

Base: main ← Head: fix/tracker-sse-abort-handling


📝 Commits (1)

  • c66afad Fix spurious abort on normal generation completion

📊 Changes

1 file changed (+17 additions, -4 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+17 -4)

📄 Description

Listen for close on reply.raw instead of req.raw and skip abort cleanup when generation has already completed successfully.

Linked issue

Closes #443

Why this change

  • Tracker agents could be aborted after the main model response finished, leaving generation stuck with no character/custom tracker updates. This fixes the SSE disconnect handling so post-processing agents are not cancelled by the wrong stream lifecycle event.

What changed

  • Moved generation abort-on-disconnect handling from the incoming request stream to the outgoing SSE response stream.
  • Added a completion guard so a normally completed generation does not trigger abort cleanup afterward.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex ran pnpm check locally and it passed.
  • Honestly fam, I don't know how to repro the issue but Codex seems very confident this will fix it shrug Merge if you think it checks out.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Summary by CodeRabbit

  • Bug Fixes

    • More reliable handling of client disconnects during streaming so in-flight work is aborted, backend-notified, and cleaned up.
    • Safeguards to ensure completed generations aren’t canceled; completion is signaled and finalized before cleanup.
    • Per-character generation now marks commits so disconnect logic respects per-character finalization and avoids premature aborts.
  • Refactor

    • Stream listener and cleanup flow simplified for more robust disconnect handling.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/454 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/6/2026 **Status:** ✅ Merged **Merged:** 5/6/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix/tracker-sse-abort-handling` --- ### 📝 Commits (1) - [`c66afad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c66afadd0a326fbac5d5f097ec8f59232898b6c5) Fix spurious abort on normal generation completion ### 📊 Changes **1 file changed** (+17 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+17 -4) </details> ### 📄 Description Listen for close on reply.raw instead of req.raw and skip abort cleanup when generation has already completed successfully. ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #443 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Tracker agents could be aborted after the main model response finished, leaving generation stuck with no character/custom tracker updates. This fixes the SSE disconnect handling so post-processing agents are not cancelled by the wrong stream lifecycle event. ## What changed <!-- List the key changes in this PR --> - Moved generation abort-on-disconnect handling from the incoming request stream to the outgoing SSE response stream. - Added a completion guard so a normally completed generation does not trigger abort cleanup afterward. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [X] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [X] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex ran `pnpm check` locally and it passed. - Honestly fam, I don't know how to repro the issue but Codex seems very confident this will fix it *shrug* Merge if you think it checks out. ## Docs and release impact - [X] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for UI changes --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * More reliable handling of client disconnects during streaming so in-flight work is aborted, backend-notified, and cleaned up. * Safeguards to ensure completed generations aren’t canceled; completion is signaled and finalized before cleanup. * Per-character generation now marks commits so disconnect logic respects per-character finalization and avoids premature aborts. * **Refactor** * Stream listener and cleanup flow simplified for more robust disconnect handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4624
No description provided.