mirror of
https://github.com/open-webui/terminals.git
synced 2026-11-05 01:37:21 +00:00
[GH-ISSUE #52] Bug: Proxy httpx.ReadTimeout when /execute?wait=300 reaches its allowed wait limit #24
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/terminals#24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Classic298 on GitHub (Aug 5, 2026).
Original GitHub issue: https://github.com/open-webui/terminals/issues/52
Summary
Terminals v0.1.0 uses a hard-coded 300 second
httpxtimeout for the internal proxy connection to a per-user Open Terminal container. Open Terminal's/executeendpoint also permitswait=300.When a caller sends
POST /p/{policy_id}/execute?wait=300, Terminals can time out while waiting for the upstream response headers, even though the per-user terminal is still handling a valid request. There is no margin for normal scheduling, process cleanup, log reading, or response serialization after the command wait reaches 300 seconds.The resulting
httpx.ReadTimeoutis unhandled by the proxy route and produces an ASGI exception / 500 response.Environment
ghcr.io/open-webui/terminals:v0.1.0ghcr.io/open-webui/open-terminal/p/{policy_id}/execute)proxy_read_timeout 1800sandproxy_send_timeout 1800sThe nginx timeout is not involved: the failure occurs on the direct Docker-network connection from Terminals to the per-user container.
Reproduction
Start Terminals v0.1.0 with the Docker backend and a policy.
Send an execute request through Terminals with a long wait, for example:
Repeat under normal service load and/or with a command that finishes close to the five-minute boundary.
Actual result
Terminals logs an unhandled exception and the caller receives a failed request. Relevant log excerpt:
The error is raised at the internal proxy request:
Root cause
In
terminals/routers/proxy.py, Terminals v0.1.0 creates its upstream client with a fixed overall timeout of 300 seconds:The proxied Open Terminal endpoint accepts
waitvalues up to 300 seconds. Thereforewait=300and the proxy's upstream read timeout have the same deadline.Even when the command itself completes within the allowed wait, the upstream still has to finish process/log handling and return response headers. Any overhead at the boundary makes the outer proxy time out first.
Expected result
A valid
/execute?wait=300request should not fail solely because the Terminals proxy has the same 300-second deadline as the endpoint's maximum permitted wait.If the upstream does not respond within the configured proxy deadline, Terminals should return a deliberate, structured gateway-timeout response rather than an unhandled ASGI stack trace.
Proposed fix
Preferred: configurable upstream proxy timeouts
Add settings such as:
Then apply them in
_get_proxy_client():The default read timeout should be greater than the maximum supported Open Terminal
/execute?waitduration. For example, 360 seconds leaves a 60-second response-processing margin.Alternative / additional improvement: derive the deadline for
/executeFor requests to
/execute, parse the validatedwaitquery value and set the per-request upstream read timeout towait + safety_margin. This avoids an arbitrary global ceiling for an endpoint that intentionally supports long-polling.Error handling
Handle
httpx.ReadTimeoutexplicitly in_proxy_request()and return a meaningful504 Gateway Timeoutresponse. Do not blindly retryPOST /executeafter a read timeout, because the child command may already have started and a retry could run it twice.Workaround
A local wrapper image that changes the internal read timeout from 300 to 360 seconds prevents the boundary timeout, but it is not maintainable because the timeout is currently hard-coded and has no environment-variable configuration.
@owui-terminator[bot] commented on GitHub (Aug 5, 2026):
🔍 Related Issues Found
I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:
Related at the proxy layer: both issues are about
_proxy_requestinterminals/routers/proxy.pysurfacing upstreamhttpxfailures as 500s instead of handling them gracefully. This one is specifically a stale-connectionRemoteProtocolError, while the new issue is a boundaryReadTimeout, but the shared missing error handling and proxy behavior make it the closest match.by Classic298
💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.
This comment was generated automatically. React with 👍 if helpful, 👎 if not.
@Classic298 commented on GitHub (Aug 8, 2026):
@tjbck