[GH-ISSUE #2416] [Issue]: 11-PROV-RUNTIME-stream-cancel-lifecycle remote streams skip unload cancellation #1183

Closed
opened 2026-10-21 05:28:29 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2416

Originally assigned to: @Xelvanis on GitHub.

Summary

11-PROV-RUNTIME-stream-cancel-lifecycle has remote-runtime cleanup drift: embedded Tauri streams are cancelled on pagehide/beforeunload, but remote /api/llm/stream streams do not install equivalent unload cleanup.

Expected behavior

Generation abort/cancel should stop live provider streams and clean active stream registries for both embedded Tauri and remote runtime, including page unload/navigation cleanup.

Actual behavior

The shared LLM API installs unload cancellation only after the remote branch returns. Embedded Tauri stream IDs are added to activeTauriStreamIds and cancelled on pagehide/beforeunload; remote streams only cancel when the passed AbortSignal fires.

Steps to reproduce

  1. Configure a remote runtime target.
  2. Start an LLM stream through llmApi.stream(...).
  3. Navigate away or unload the page without explicitly aborting the stream controller.
  4. Compare with embedded Tauri, where active Tauri stream IDs are cancelled on unload.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor parityscan for #2410
  • Run mode: remote runtime compared with Tauri desktop
  • OS + version: not relevant; static trace
  • Node + pnpm versions: not relevant; static trace
  • Rust version, if relevant: not relevant; static trace
  • Remote Runtime URL configured? yes
  • Provider, model, or integration, if relevant: LLM streaming provider transport

Logs, screenshots, or video

Static proof:

  • Remote branch returns before unload cancellation is installed: src/shared/api/llm-api.ts:59
  • Tauri unload cancellation is installed after the remote branch: src/shared/api/llm-api.ts:73
  • Tauri unload handler cancels active Tauri stream IDs: src/shared/api/llm-api.ts:22
  • Remote explicit cancel route exists: src/shared/api/remote-runtime.ts:618, src-tauri/src/http_server.rs:1237
  • Rust stream registry supports active and pending cancellation cleanup: src-tauri/src/state.rs:136
  • Legacy generation cleanup aborted active generation and removed the chat entry: packages/server/src/routes/generate.routes.ts:1924, packages/server/src/routes/generate.routes.ts:11156 on main

Regression notes

Legacy /api/generate tracked active generations and aborted/removed them on close or explicit /api/generate/abort. Refactor per-stream cancellation is stronger, but remote streams lack the unload cleanup that embedded streams have.

Source surface: #2410, 11-PROV-RUNTIME-stream-cancel-lifecycle.

Additional context

Acceptance criteria:

  • Remote LLM streams get unload/pagehide cleanup equivalent to embedded Tauri streams.
  • Cleanup calls /api/llm/stream/:stream_id/cancel for active remote stream IDs.
  • Active and pending Rust stream registry entries are cleaned after cancellation.
  • Add focused proof for remote unload cancellation and embedded behavior remains intact.
  • Keep the surface ID 11-PROV-RUNTIME-stream-cancel-lifecycle visible in the fix notes.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2416 Originally assigned to: @Xelvanis on GitHub. ## Summary `11-PROV-RUNTIME-stream-cancel-lifecycle` has remote-runtime cleanup drift: embedded Tauri streams are cancelled on `pagehide`/`beforeunload`, but remote `/api/llm/stream` streams do not install equivalent unload cleanup. ## Expected behavior Generation abort/cancel should stop live provider streams and clean active stream registries for both embedded Tauri and remote runtime, including page unload/navigation cleanup. ## Actual behavior The shared LLM API installs unload cancellation only after the remote branch returns. Embedded Tauri stream IDs are added to `activeTauriStreamIds` and cancelled on `pagehide`/`beforeunload`; remote streams only cancel when the passed `AbortSignal` fires. ## Steps to reproduce 1. Configure a remote runtime target. 2. Start an LLM stream through `llmApi.stream(...)`. 3. Navigate away or unload the page without explicitly aborting the stream controller. 4. Compare with embedded Tauri, where active Tauri stream IDs are cancelled on unload. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor parityscan for #2410 - Run mode: remote runtime compared with Tauri desktop - OS + version: not relevant; static trace - Node + pnpm versions: not relevant; static trace - Rust version, if relevant: not relevant; static trace - Remote Runtime URL configured? yes - Provider, model, or integration, if relevant: LLM streaming provider transport ## Logs, screenshots, or video Static proof: - Remote branch returns before unload cancellation is installed: `src/shared/api/llm-api.ts:59` - Tauri unload cancellation is installed after the remote branch: `src/shared/api/llm-api.ts:73` - Tauri unload handler cancels active Tauri stream IDs: `src/shared/api/llm-api.ts:22` - Remote explicit cancel route exists: `src/shared/api/remote-runtime.ts:618`, `src-tauri/src/http_server.rs:1237` - Rust stream registry supports active and pending cancellation cleanup: `src-tauri/src/state.rs:136` - Legacy generation cleanup aborted active generation and removed the chat entry: `packages/server/src/routes/generate.routes.ts:1924`, `packages/server/src/routes/generate.routes.ts:11156` on `main` ## Regression notes Legacy `/api/generate` tracked active generations and aborted/removed them on close or explicit `/api/generate/abort`. Refactor per-stream cancellation is stronger, but remote streams lack the unload cleanup that embedded streams have. Source surface: #2410, `11-PROV-RUNTIME-stream-cancel-lifecycle`. ## Additional context Acceptance criteria: - Remote LLM streams get unload/pagehide cleanup equivalent to embedded Tauri streams. - Cleanup calls `/api/llm/stream/:stream_id/cancel` for active remote stream IDs. - Active and pending Rust stream registry entries are cleaned after cancellation. - Add focused proof for remote unload cancellation and embedded behavior remains intact. - Keep the surface ID `11-PROV-RUNTIME-stream-cancel-lifecycle` visible in the fix notes. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:29 +07:00
  • closed this issue
  • added the
    bug
    label
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#1183
No description provided.