[PR #871] [MERGED] Fix Conversation generation abort on passive disconnect #4812

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/871
Author: @Promansis
Created: 5/15/2026
Status: ✅ Merged
Merged: 5/15/2026
Merged by: @Promansis

Base: staging ← Head: fix/853-conversation-focus-network-error


📝 Commits (1)

  • 8afd8c0 Fix issue 853 conversation disconnect abort

📊 Changes

3 files changed (+54 additions, -2 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+20 -1)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+7 -0)
📝 packages/server/test/generate-route-utils.test.ts (+27 -1)

📄 Description

Linked issue

Closes #853

Why this change

  • In Docker Conversation mode, a passive SSE disconnect after the user switches focus could be treated like an explicit cancel, aborting the LinkAPI provider call and surfacing a generic network error.

What changed

  • Kept explicit /api/generate/abort cancellation behavior intact.
  • Changed passive SSE close handling so normal Conversation generations continue and persist even if the client disconnects mid-generation.
  • Guarded server-side SSE writes after passive disconnect so background completion does not throw on a closed response stream.
  • Added regression coverage for the passive-disconnect abort policy.

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

Automated verification performed:

  • pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/generate-route-utils.test.ts passed.
  • pnpm check passed.

Suggested manual verification:

  1. Run Marinara Engine through Docker with a LinkAPI text connection configured.
  2. Open or create a Conversation-mode chat using that connection.
  3. Send a message that takes long enough to generate that you can switch focus while it is running.
  4. Switch to another browser tab, another app, or another screen before the response completes.
  5. Return to Marinara Engine and confirm the assistant response completes or appears after refresh without a generic LinkAPI network error.
  6. Repeat once using the Stop button during generation and confirm explicit cancellation still stops the request.

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)

No docs, schema, release metadata, dependency, or version files were changed.

UI evidence (if applicable)

image

N/A. This is a server-side generation lifecycle fix; no UI surface was changed.


🔄 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/871 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 5/15/2026 **Status:** ✅ Merged **Merged:** 5/15/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix/853-conversation-focus-network-error` --- ### 📝 Commits (1) - [`8afd8c0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8afd8c02afec451860037b20327a9c32fcc0b7ae) Fix issue 853 conversation disconnect abort ### 📊 Changes **3 files changed** (+54 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+20 -1) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+7 -0) 📝 `packages/server/test/generate-route-utils.test.ts` (+27 -1) </details> ### 📄 Description ## 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 #853 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - In Docker Conversation mode, a passive SSE disconnect after the user switches focus could be treated like an explicit cancel, aborting the LinkAPI provider call and surfacing a generic network error. ## What changed <!-- List the key changes in this PR --> - Kept explicit `/api/generate/abort` cancellation behavior intact. - Changed passive SSE close handling so normal Conversation generations continue and persist even if the client disconnects mid-generation. - Guarded server-side SSE writes after passive disconnect so background completion does not throw on a closed response stream. - Added regression coverage for the passive-disconnect abort policy. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] 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. --> Automated verification performed: - `pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/generate-route-utils.test.ts` passed. - `pnpm check` passed. Suggested manual verification: 1. Run Marinara Engine through Docker with a LinkAPI text connection configured. 2. Open or create a Conversation-mode chat using that connection. 3. Send a message that takes long enough to generate that you can switch focus while it is running. 4. Switch to another browser tab, another app, or another screen before the response completes. 5. Return to Marinara Engine and confirm the assistant response completes or appears after refresh without a generic LinkAPI `network error`. 6. Repeat once using the Stop button during generation and confirm explicit cancellation still stops the request. ## Docs and release impact - [x] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [x] Version/release files updated (only if this PR includes a version bump) No docs, schema, release metadata, dependency, or version files were changed. ## UI evidence (if applicable) <img width="292" height="213" alt="image" src="https://github.com/user-attachments/assets/8fa4d37f-d870-4895-bfd9-ab4efc7191f2" /> N/A. This is a server-side generation lifecycle fix; no UI surface was changed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:51 +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#4812
No description provided.