[PR #148] fix: make uvicorn's keep-alive timeout configurable, default 75s #139

Open
opened 2026-10-18 21:11:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-terminal/pull/148
Author: @dvystrcil
Created: 8/1/2026
Status: 🔄 Open

Base: main ← Head: fix/uvicorn-keep-alive-timeout


📝 Commits (1)

  • 94716b8 fix: make uvicorn's keep-alive timeout configurable, default 75s

📊 Changes

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

View changed files

📝 CHANGELOG.md (+6 -0)
📝 open_terminal/cli.py (+8 -2)
📝 open_terminal/env.py (+13 -0)

📄 Description

Problem

I run open-terminal behind Open WebUI as a tool backend. Occasionally a tool call would fail with ConnectionResetError/Connection reset by peer even though the underlying command had actually completed successfully.

Root cause: uvicorn's default timeout_keep_alive is 5 seconds, which can be shorter than the client's own HTTP connection-pool reuse window. If the client (Open WebUI, or any pooled HTTP client) holds a connection open longer than 5s of idle time and then reuses it, the server has already closed it server-side -- the write lands on a dead socket and the client sees a reset, even though nothing about the request itself was wrong.

Fix

Adds OPEN_TERMINAL_UVICORN_TIMEOUT_KEEP_ALIVE (or uvicorn_timeout_keep_alive in config.toml), following the exact same pattern as the existing OPEN_TERMINAL_UVICORN_LOOP option. Defaults to 75s, matching gunicorn/nginx's common default and comfortably exceeding most client-side pool idle timeouts.

Testing

No test harness exists in this repo currently, so verified manually: built a venv from this branch (pip install -e .), started the server (open-terminal run), confirmed it boots cleanly and serves /health correctly with the new parameter wired through uvicorn.run(). Confirmed timeout_keep_alive is a real, documented uvicorn.run() parameter via inspect.signature.

Happy to adjust the default or naming convention if you'd prefer something different.


🔄 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/open-webui/open-terminal/pull/148 **Author:** [@dvystrcil](https://github.com/dvystrcil) **Created:** 8/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/uvicorn-keep-alive-timeout` --- ### 📝 Commits (1) - [`94716b8`](https://github.com/open-webui/open-terminal/commit/94716b82bb4cb3ffb8a0e48406590cde62a80bd2) fix: make uvicorn's keep-alive timeout configurable, default 75s ### 📊 Changes **3 files changed** (+27 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+6 -0) 📝 `open_terminal/cli.py` (+8 -2) 📝 `open_terminal/env.py` (+13 -0) </details> ### 📄 Description ## Problem I run open-terminal behind Open WebUI as a tool backend. Occasionally a tool call would fail with `ConnectionResetError`/`Connection reset by peer` even though the underlying command had actually completed successfully. Root cause: uvicorn's default `timeout_keep_alive` is 5 seconds, which can be shorter than the client's own HTTP connection-pool reuse window. If the client (Open WebUI, or any pooled HTTP client) holds a connection open longer than 5s of idle time and then reuses it, the server has already closed it server-side -- the write lands on a dead socket and the client sees a reset, even though nothing about the request itself was wrong. ## Fix Adds `OPEN_TERMINAL_UVICORN_TIMEOUT_KEEP_ALIVE` (or `uvicorn_timeout_keep_alive` in `config.toml`), following the exact same pattern as the existing `OPEN_TERMINAL_UVICORN_LOOP` option. Defaults to 75s, matching gunicorn/nginx's common default and comfortably exceeding most client-side pool idle timeouts. ## Testing No test harness exists in this repo currently, so verified manually: built a venv from this branch (`pip install -e .`), started the server (`open-terminal run`), confirmed it boots cleanly and serves `/health` correctly with the new parameter wired through `uvicorn.run()`. Confirmed `timeout_keep_alive` is a real, documented uvicorn.run() parameter via `inspect.signature`. Happy to adjust the default or naming convention if you'd prefer something different. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
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
open-webui/open-terminal#139
No description provided.