[GH-ISSUE #1716] [Issue]: llm_stream_channel remains pending after visible generation finishes #850

Closed
opened 2026-10-21 05:22:06 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

CrabNebula DevTools can show an embedded Tauri llm_stream_channel command still running long after the foreground generation appears complete. One observed row was:

command: llm_stream_channel 19:41:24 1020502.04ms streamid: cd44cadb-80b4-4c63-a472-59491049baee uri: http://ipc.localhost/llm_stream_channel

Code inspection points at a stuck stream/IPC lifetime rather than a visible generation state problem: the foreground UI can release after persisted generation events, while the shared LLM stream generator still waits for the underlying Tauri command promise to resolve.

Expected behavior

When a generation finishes, errors, or is cancelled, the embedded Tauri llm_stream_channel command should resolve promptly and unregister its stream id. DevTools should not show old LLM stream commands increasing in duration after the user-visible LLM work is done.

Actual behavior

At least one llm_stream_channel command remains pending for ~17 minutes and continues increasing in duration in CrabNebula DevTools after the user considers the LLM generation finished.

The likely failure path from local inspection:

  • src/shared/api/llm-api.ts marks the JS stream completed only when the channel receives done or error, but then still awaits the invokeTauri("llm_stream_channel", ...) command promise before the async generator fully returns.
  • src-tauri/src/commands/storage/llm.rs resolves llm_stream_channel only when marinara_llm::stream_events(...) returns or cancellation fires.
  • src-tauri/crates/llm/src/lib.rs emits the terminal done event only after the provider-specific stream reader returns.
  • The provider stream readers consume response.bytes_stream() until EOF. They do not appear to enforce an app-side idle/read timeout or always break on provider semantic terminal events such as [DONE].

This leaves two plausible but related ways for the command to outlive the visible generation:

  • A provider or compatible endpoint leaves the HTTP stream open after sending enough content, so Rust never emits done and the Tauri command stays pending.
  • Rust sends a terminal channel event, but the frontend then waits indefinitely at await command if the embedded Tauri command promise does not resolve promptly.

Steps to reproduce

  1. Run the refactor branch in Tauri desktop mode.
  2. Open CrabNebula DevTools.
  3. Start an LLM generation using streaming.
  4. Wait until the UI appears to have completed the generation.
  5. Inspect IPC command rows for llm_stream_channel.

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
  • 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 at local inspection commit 1d1fd0ca
  • Run mode: Tauri desktop
  • OS + version: Ubuntu Linux, kernel 6.8.0-117-generic
  • Node + pnpm versions: Node v24.15.0, pnpm 10.33.2
  • Rust version, if relevant: rustc 1.95.0 (59807616e 2026-04-14)
  • Remote Runtime URL configured? not relevant to observed http://ipc.localhost embedded command
  • Provider, model, or integration, if relevant: LLM streaming provider not captured in the DevTools row

Logs, screenshots, or video

Observed DevTools row:

command: llm_stream_channel 19:41:24 1020502.04ms streamid: cd44cadb-80b4-4c63-a472-59491049baee uri: http://ipc.localhost/llm_stream_channel

Relevant local code paths:

  • src/shared/api/llm-api.ts:92-115
  • src-tauri/src/commands/storage/llm.rs:172-204
  • src-tauri/crates/llm/src/lib.rs:99-124
  • src-tauri/crates/llm/src/lib.rs:876-894 for the OpenAI-compatible byte stream loop; equivalent EOF-driven loops exist for other streaming providers.

Regression notes

Unknown. This was observed on the refactor branch during normal app use with CrabNebula DevTools open.

Additional context

This should be investigated separately from eager TTS/regex config reads. Those are ordinary React Query calls and not intentionally long-lived, while llm_stream_channel is a streaming IPC command whose lifecycle spans Rust provider transport, Tauri channel events, and the frontend async generator.

A robust fix probably needs a lifecycle contract such as:

  • stop reading provider SSE once a provider terminal event is seen,
  • add an app-side idle/read timeout for streaming providers,
  • ensure cancellation is fired if the frontend generator exits early,
  • and avoid waiting forever on the embedded command promise after a terminal channel event has already been received.

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 (May 31, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1716 Originally assigned to: @Promansis on GitHub. ## Summary CrabNebula DevTools can show an embedded Tauri `llm_stream_channel` command still running long after the foreground generation appears complete. One observed row was: `command: llm_stream_channel 19:41:24 1020502.04ms streamid: cd44cadb-80b4-4c63-a472-59491049baee uri: http://ipc.localhost/llm_stream_channel` Code inspection points at a stuck stream/IPC lifetime rather than a visible generation state problem: the foreground UI can release after persisted generation events, while the shared LLM stream generator still waits for the underlying Tauri command promise to resolve. ## Expected behavior When a generation finishes, errors, or is cancelled, the embedded Tauri `llm_stream_channel` command should resolve promptly and unregister its stream id. DevTools should not show old LLM stream commands increasing in duration after the user-visible LLM work is done. ## Actual behavior At least one `llm_stream_channel` command remains pending for ~17 minutes and continues increasing in duration in CrabNebula DevTools after the user considers the LLM generation finished. The likely failure path from local inspection: - `src/shared/api/llm-api.ts` marks the JS stream completed only when the channel receives `done` or `error`, but then still awaits the `invokeTauri("llm_stream_channel", ...)` command promise before the async generator fully returns. - `src-tauri/src/commands/storage/llm.rs` resolves `llm_stream_channel` only when `marinara_llm::stream_events(...)` returns or cancellation fires. - `src-tauri/crates/llm/src/lib.rs` emits the terminal `done` event only after the provider-specific stream reader returns. - The provider stream readers consume `response.bytes_stream()` until EOF. They do not appear to enforce an app-side idle/read timeout or always break on provider semantic terminal events such as `[DONE]`. This leaves two plausible but related ways for the command to outlive the visible generation: - A provider or compatible endpoint leaves the HTTP stream open after sending enough content, so Rust never emits `done` and the Tauri command stays pending. - Rust sends a terminal channel event, but the frontend then waits indefinitely at `await command` if the embedded Tauri command promise does not resolve promptly. ## Steps to reproduce 1. Run the refactor branch in Tauri desktop mode. 2. Open CrabNebula DevTools. 3. Start an LLM generation using streaming. 4. Wait until the UI appears to have completed the generation. 5. Inspect IPC command rows for `llm_stream_channel`. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [x] Chat mode - [x] Roleplay mode - [x] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [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` at local inspection commit `1d1fd0ca` - Run mode: Tauri desktop - OS + version: Ubuntu Linux, kernel `6.8.0-117-generic` - Node + pnpm versions: Node `v24.15.0`, pnpm `10.33.2` - Rust version, if relevant: `rustc 1.95.0 (59807616e 2026-04-14)` - Remote Runtime URL configured? not relevant to observed `http://ipc.localhost` embedded command - Provider, model, or integration, if relevant: LLM streaming provider not captured in the DevTools row ## Logs, screenshots, or video Observed DevTools row: `command: llm_stream_channel 19:41:24 1020502.04ms streamid: cd44cadb-80b4-4c63-a472-59491049baee uri: http://ipc.localhost/llm_stream_channel` Relevant local code paths: - `src/shared/api/llm-api.ts:92-115` - `src-tauri/src/commands/storage/llm.rs:172-204` - `src-tauri/crates/llm/src/lib.rs:99-124` - `src-tauri/crates/llm/src/lib.rs:876-894` for the OpenAI-compatible byte stream loop; equivalent EOF-driven loops exist for other streaming providers. ## Regression notes Unknown. This was observed on the refactor branch during normal app use with CrabNebula DevTools open. ## Additional context This should be investigated separately from eager TTS/regex config reads. Those are ordinary React Query calls and not intentionally long-lived, while `llm_stream_channel` is a streaming IPC command whose lifecycle spans Rust provider transport, Tauri channel events, and the frontend async generator. A robust fix probably needs a lifecycle contract such as: - stop reading provider SSE once a provider terminal event is seen, - add an app-side idle/read timeout for streaming providers, - ensure cancellation is fired if the frontend generator exits early, - and avoid waiting forever on the embedded command promise after a terminal channel event has already been received. ## 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:22:06 +07:00
Author
Owner

@cha1latte commented on GitHub (May 31, 2026):

Tracking note: PR #1723 is open against refactor with Closes #1716, so tagging this as in-pr while review/merge finishes.

<!-- gh-comment-id:4587587852 --> @cha1latte commented on GitHub (May 31, 2026): Tracking note: PR #1723 is open against `refactor` with `Closes #1716`, so tagging this as `in-pr` while review/merge finishes.
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#850
No description provided.