[Bug] Remote SSH workspace: Write/Edit permanently fail with "Limit exceeded: handle limit reached" after long session (russh-sftp client-side handle leak)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- rust, tauri
- Domain
- desktop, networking
Research direction
Locate the Rust remote SSH/SFTP client code and its handle lifecycle, using the russh_sftp::client::rawsession evidence and upstream remotefs-rs-ssh PR #22 as starting points. Reproduce the long-session failure with repeated Read/Write/Edit operations, then verify that the chosen fix prevents handle exhaustion or recovers the SFTP session.
Written by the indexing model from the issue text.
Description
Summary
远程 SSH 工作区在长会话高强度使用文件工具后,所有 Write/Edit 持续失败,报 Limit exceeded: handle limit reached,等待 30 分钟以上不自愈,只能重启桌面端恢复。同期 Read/Glob/Grep/终端均正常。
定位证据指向 russh-sftp 客户端侧句柄表泄漏(见下)。
Area
Desktop app
Reproduction or evidence
- 连接远程 SSH 工作区,长时间高频使用文件工具(大量分块 Read、多次 Write/Edit);
- 累计足够多打开/关闭循环后触发;
- 此后所有
Write/Edit持续失败,间隔 30 分钟以上的多次重试均不恢复; Read/Glob/Grep/ExecCommand全部正常。
Write:
Tool 'Write' failed (execution_error): Tool error: Failed to write file:
Failed to create remote file '/path/to/workspace/.bitfun/tmp/write_xxxxxxxx.tmp':
Limit exceeded: handle limit reached
Edit(内置 re-read 步骤即失败):
File /path/to/file.py could not be re-read before editing
(Tool error: Failed to read file: Failed to open remote file '/path/to/file.py':
Limit exceeded: handle limit reached)
注意不对称性:普通 Read 工具同一时刻仍能成功打开同一文件,而 Edit 内部 re-read 与 Write 的新建 open 失败——疑似读/写两条 SFTP 会话中写路径的句柄表先耗尽。
-
handle limit reached错误串在 bitfun-desktop 二进制 strings 中与russh_sftp::client::rawsession、attempt to close more handles than exist相邻——错误来自 russh-sftp 客户端侧会话句柄表,不是服务端 sshd(远端 sftp-server 进程仅 7 个 fd,远未达任何限制)。 -
上游生态已确认同类机制:remotefs-rs-ssh PR#22(https://github.com/remotefs-rs/remotefs-rs-ssh/pull/22)原文:
russh-sftp's
File::dropcloses handles viaclose_nowait, which frees the handle server-side but never decrements the client's open-handle counter. Reads (one handle per chunk) and writes (one handle per upload) relied onDrop, so the counter climbed monotonically until the negotiated limit was reached, failing later operations withLimit exceeded: Handle limit reached.与本例现象逐点吻合:计数单调增长、达到协商上限后新 open 全失败、不自愈。
- SFTP 文件句柄关闭使用 awaited close/shutdown(等 close 响应后再递减客户端计数器),不依赖
Drop/close_nowait; - 读路径若按 chunk 开关 handle,考虑单 handle + seek 复用;
- 收到
Handle limit reached时自动重建 SFTP 会话(句柄表随会话重置)实现自愈,而不是让错误永久驻留; - 建议在日志中输出 open-handle 计数与上限,便于确认泄漏速率。
Environment, if relevant
- BitFun 桌面端 0.2.18(macOS,Tauri/Rust 后端)
- 工作区类型:Remote SSH(目标 macOS 主机,OpenSSH + sftp-server)
- 桌面进程连续运行 1 天 9 小时+;触发前约 1.5~2 小时高强度使用(数十次大文件分块 Read + 若干次 Write/Edit)
- 期间存在两条 sftp-server 进程(不同时间各起一条),疑似读/写走不同 SFTP 通道
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 236
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 619
Contributor guide
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.
More from GCWing/OpenBitFun
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GCWing/OpenBitFun#3213 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GCWing/OpenBitFun#2363 ·
-
question
Difficulty 1/5 Under an hour Newbie friendliness 78/100
GCWing/OpenBitFun#2340 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
GCWing/OpenBitFun#3210 ·
-
GCWing/OpenBitFun#3195 · 2 comments · 1 assignee ·
All issues in GCWing/OpenBitFun
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
state:needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
zed-industries/zed#64680 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
RustPython/RustPython#8802 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TheLarkInn/aipm#2390 ·