open-webui / open-webui/computer
bug: interactive terminal session freezes long-running processes when the browser client disconnects
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 569
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
bug: interactive terminal session freezes long-running processes when the browser client disconnects
Bug description
Interactive (PTY) terminal sessions only drain their PTY output while a
browser WebSocket client is attached. If the client disconnects — closed tab,
suspended laptop, browser backgrounded/killed — nothing reads the PTY master
fd anymore, and the kernel PTY buffer (~64 KB) eventually fills up. Any
long-running process attached to the terminal (e.g. a CLI agent, a build, a
tail) then blocks on write() until a client reconnects. Output produced
while detached is also lost beyond the kernel buffer.
This makes the terminal unusable as a place to run anything long-lived that
produces output.
To Reproduce
- Open an interactive terminal session and start a process that emits more than ~64 KB of output over time (e.g.
yes | head -c 100Mor a long build). - Close the browser tab (or let the connection drop) while it runs.
- Reopen later and observe: the process is frozen once the kernel buffer filled, and output emitted while detached is gone.
Expected behavior
The child process should keep running — and its output should be retained —
independently of whether a browser client is connected, similar to how
command sessions already buffer output.
Suggested approach
- Move PTY draining into the session itself: a session-owned drain task started at session creation that reads PTY output into a capped in-memory buffer (with a monotonic byte counter), independent of clients.
- Make
terminal_wsa subscriber that tails the session buffer via byte offset (same pattern as command sessions) instead of being the sole reader; reconnecting clients resume from their offset. - On the frontend, re-establish the terminal WebSocket on
visibilitychangeif the connection died while the tab was hidden (browsers throttle/suspend background tabs and can silently kill the socket).
Environment
- Latest main
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the terminal_ws entry point and session creation, then compare how command sessions buffer output. Trace PTY master reads and the frontend visibilitychange handling. Done means the process continues and output is retained while disconnected, with reconnecting clients able to resume it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100