[PR #4175] [MERGED] fix(noodle): honor CHAT_GENERATION_TIMEOUT_MS for background generation #6267

Closed
opened 2026-10-23 04:08:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4175
Author: @Gunterlie
Created: 7/27/2026
Status: ✅ Merged
Merged: 7/27/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/4174-noodle-headers-timeout


📝 Commits (1)

  • 2a6ea3d fix(noodle): honor CHAT_GENERATION_TIMEOUT_MS for background generation

📊 Changes

4 files changed (+17 additions, -9 deletions)

View changed files

📝 .env.example (+4 -1)
📝 CHANGELOG.md (+1 -0)
📝 docs/CONFIGURATION.md (+1 -1)
📝 packages/server/src/services/llm/base-provider.ts (+11 -7)

📄 Description

Linked issue

Closes #4174

Why this change

  • Refreshing the Noodle timeline against a slow local model failed after ~5 minutes with HeadersTimeoutError / "fetch failed", for both the manual Refresh timeline button and the automatic refresh.
  • The reporter raised every *_TIMEOUT_MS value in .env, including CHAT_GENERATION_TIMEOUT_MS=3600000, and the error persisted — there was no setting that could fix this.
  • Root cause: llmFetch in packages/server/src/services/llm/base-provider.ts hard-coded the undici headersTimeout (time to first byte) to 5 minutes. CHAT_GENERATION_TIMEOUT_MS only reached undici through withLlmRequestTimeout(...), which is used solely by generate.routes.ts, game.routes.ts, and the long-term-memory runtime. Noodle calls provider.chatComplete directly with stream: false, so it always got the fixed 5 minutes — as did every other unwrapped background generation path. Present since 7577dd930 (2026-04-02), not a regression from the recent Noodle work.

What changed

  • packages/server/src/services/llm/base-provider.ts: the default undici agent options now read getChatGenerationTimeoutMs() for headersTimeout instead of the hard-coded LLM_HEADERS_TIMEOUT constant. The 2-minute inter-chunk bodyTimeout is unchanged, so half-open streams still cannot hang forever. The default is still 300 000 ms — behavior is identical for anyone who does not set the variable.
  • .env.example and docs/CONFIGURATION.md: document that CHAT_GENERATION_TIMEOUT_MS also covers background generation with no timeout of its own (Noodle timeline refresh, Noodler replies). The configuration table previously stated the opposite.
  • CHANGELOG.md: entry under Unreleased → Fixed.

Deliberately not added: a Noodle-specific env var, or withLlmRequestTimeout wrapping at each call site. One shared default fixes every caller; a separate knob is only worth it if Noodle ever needs a budget different from chat.

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

⚠️ Written by an AI agent as a to-do list — nothing below has been performed by a human yet. pnpm check was run by the agent and exited 0, but the box stays unticked until a maintainer confirms it.

  • Manually verify in the app: set CHAT_GENERATION_TIMEOUT_MS=3600000, point at a local model slow enough to take more than 5 minutes on a timeline refresh, click Refresh timeline in Noodle, and confirm it completes instead of failing with HeadersTimeoutError.
  • Manually verify the automatic Noodle refresh under the same conditions.
  • Manually verify the regression case: with CHAT_GENERATION_TIMEOUT_MS unset, confirm ordinary Conversation and Roleplay streaming still behaves as before (default remains 5 minutes).
  • Manually verify a genuinely unreachable/hanging provider still fails rather than hanging forever when the variable is set to the 3 600 000 ms maximum.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/CONFIGURATION.md changed, so the docs-i18n language packs (Spanish, German) need the matching edit or a [docs-i18n] docs/CONFIGURATION.md follow-up issue.

UI evidence (if applicable)

Not applicable — server-side timeout configuration, no UI change.

Summary by CodeRabbit

  • Bug Fixes

    • Chat generation requests now use the configured timeout for time-to-first-byte responses.
    • Prevents slow local models from causing timeline refreshes to fail after the fixed five-minute limit.
    • Inter-chunk response timeout behavior remains unchanged.
  • Documentation

    • Updated configuration guidance and changelog details for CHAT_GENERATION_TIMEOUT_MS, including its background-generation coverage and default value.

🔄 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/4175 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/27/2026 **Status:** ✅ Merged **Merged:** 7/27/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/4174-noodle-headers-timeout` --- ### 📝 Commits (1) - [`2a6ea3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a6ea3d8eeb90f5a5682f9846ff1855fc7686d1c) fix(noodle): honor CHAT_GENERATION_TIMEOUT_MS for background generation ### 📊 Changes **4 files changed** (+17 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+4 -1) 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/CONFIGURATION.md` (+1 -1) 📝 `packages/server/src/services/llm/base-provider.ts` (+11 -7) </details> ### 📄 Description ## Linked issue Closes #4174 ## Why this change - Refreshing the Noodle timeline against a slow local model failed after ~5 minutes with `HeadersTimeoutError` / "fetch failed", for both the manual **Refresh timeline** button and the automatic refresh. - The reporter raised every `*_TIMEOUT_MS` value in `.env`, including `CHAT_GENERATION_TIMEOUT_MS=3600000`, and the error persisted — there was no setting that could fix this. - Root cause: `llmFetch` in `packages/server/src/services/llm/base-provider.ts` hard-coded the undici `headersTimeout` (time to first byte) to 5 minutes. `CHAT_GENERATION_TIMEOUT_MS` only reached undici through `withLlmRequestTimeout(...)`, which is used solely by `generate.routes.ts`, `game.routes.ts`, and the long-term-memory runtime. Noodle calls `provider.chatComplete` directly with `stream: false`, so it always got the fixed 5 minutes — as did every other unwrapped background generation path. Present since `7577dd930` (2026-04-02), not a regression from the recent Noodle work. ## What changed - `packages/server/src/services/llm/base-provider.ts`: the default undici agent options now read `getChatGenerationTimeoutMs()` for `headersTimeout` instead of the hard-coded `LLM_HEADERS_TIMEOUT` constant. The 2-minute inter-chunk `bodyTimeout` is unchanged, so half-open streams still cannot hang forever. The default is still 300 000 ms — behavior is identical for anyone who does not set the variable. - `.env.example` and `docs/CONFIGURATION.md`: document that `CHAT_GENERATION_TIMEOUT_MS` also covers background generation with no timeout of its own (Noodle timeline refresh, Noodler replies). The configuration table previously stated the opposite. - `CHANGELOG.md`: entry under Unreleased → Fixed. Deliberately **not** added: a Noodle-specific env var, or `withLlmRequestTimeout` wrapping at each call site. One shared default fixes every caller; a separate knob is only worth it if Noodle ever needs a budget different from chat. ## 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 ⚠️ Written by an AI agent as a to-do list — nothing below has been performed by a human yet. `pnpm check` was run by the agent and exited 0, but the box stays unticked until a maintainer confirms it. - Manually verify in the app: set `CHAT_GENERATION_TIMEOUT_MS=3600000`, point at a local model slow enough to take more than 5 minutes on a timeline refresh, click **Refresh timeline** in Noodle, and confirm it completes instead of failing with `HeadersTimeoutError`. - Manually verify the automatic Noodle refresh under the same conditions. - Manually verify the regression case: with `CHAT_GENERATION_TIMEOUT_MS` unset, confirm ordinary Conversation and Roleplay streaming still behaves as before (default remains 5 minutes). - Manually verify a genuinely unreachable/hanging provider still fails rather than hanging forever when the variable is set to the 3 600 000 ms maximum. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/CONFIGURATION.md` changed, so the `docs-i18n` language packs (Spanish, German) need the matching edit or a `[docs-i18n] docs/CONFIGURATION.md` follow-up issue. ## UI evidence (if applicable) Not applicable — server-side timeout configuration, no UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Chat generation requests now use the configured timeout for time-to-first-byte responses. * Prevents slow local models from causing timeline refreshes to fail after the fixed five-minute limit. * Inter-chunk response timeout behavior remains unchanged. * **Documentation** * Updated configuration guidance and changelog details for `CHAT_GENERATION_TIMEOUT_MS`, including its background-generation coverage and default value. <!-- 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-23 04:08:46 +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#6267
No description provided.