Skip to content

fix(http): apply settings' httpIdleTimeoutMs to the Web UI - #1127

Open
QuickLyx wants to merge 1 commit into
agegr:mainfrom
QuickLyx:fix/http-idle-timeout-from-settings
Open

QuickLyx wants to merge 1 commit into
agegr:mainfrom
QuickLyx:fix/http-idle-timeout-from-settings

Conversation

@QuickLyx

@QuickLyx QuickLyx commented Oct 8, 2026

Copy link
Copy Markdown

Fixes #1126

Problem

registerNodeInstrumentation() called configureHttpDispatcher() with no timeout, so the Web UI always kept DEFAULT_HTTP_IDLE_TIMEOUT_MS (five minutes) and never read httpIdleTimeoutMs. That value is undici's bodyTimeout on the global dispatcher, an idle timeout that fires when the response body has had no data for that long, so a provider stream that stayed quiet for five minutes ended with a bare terminated while the same setting applied correctly to CLI sessions.

Change

  • lib/http-dispatcher.ts — add readHttpIdleTimeoutMs(agentDir), which reads the agent directory's settings.json the way the CLI reads it. A missing file, a file that does not parse, an absent key, or a value the CLI would reject returns undefined, so the existing default stays in place. The read goes through readRegularFileText, so a FIFO or a device there throws instead of blocking startup.
  • instrumentation-node.ts — pass the value through.
  • lib/http-dispatcher.test.mjs — cover the reader: missing file, broken JSON, absent key, negative value, null, a non-object file, a configured value, 0, "disabled", a byte-order mark, and PI_CODING_AGENT_DIR.

Testing

node --experimental-strip-types --test lib/http-dispatcher.test.mjs
# tests 2 | pass 2 | fail 0

The existing proxy test still passes unchanged.

Notes

  • Only the global settings file is read. The dispatcher is configured once at startup, before any project is selected, so a project's .pi/settings.json cannot apply here.
  • The agent directory is resolved locally rather than through the SDK's getAgentDir(). This module runs in Next.js instrumentation, where importing the SDK costs about a second of startup time, while undici — the only other dependency here — costs about a tenth of one. The resolution mirrors getAgentDir(): PI_CODING_AGENT_DIR, ~ expanded, otherwise ~/.pi/agent.
  • Without httpIdleTimeoutMs, behavior is unchanged: the five-minute default.

`registerNodeInstrumentation` called `configureHttpDispatcher()` with no timeout, so the Web UI always used the built-in five minutes and ignored the user's `httpIdleTimeoutMs`. A provider stream that stayed quiet for longer was aborted with a bare `terminated`, while the same setting applied correctly to CLI sessions.

Read the agent directory's `settings.json` the way the CLI does and pass the value to the dispatcher, so both surfaces honor one setting.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web UI ignores httpIdleTimeoutMs, so provider streams that stay quiet for five minutes are aborted

1 participant