CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

在多个终端中使用一段时间后会自动卡死

Open Royal-zay opened this issue 6 months ago • 8 comments

Description

Steps to reproduce

应用在使用一段时间后自动卡死,必须关闭终端在启动才可以使用

Expected behavior

Actual behavior

Environment

  • OS: kali、macos
  • DeepSeek CLI version: 0.8.14
  • Model: DeepSeek-v4-pro
  • Shell:

Logs or screenshots

Royal-zay avatar May 06 '26 08:05 Royal-zay

感谢报告,这个像是长时间运行后的 runtime / terminal 卡死问题,我不想只凭现象猜原因。

如果方便的话,请补充这几项,我会按这个方向继续查:

- 终端和 shell:比如 WezTerm / Warp / Terminal / iTerm,zsh / powershell / bash
- 安装方式:npm / brew / cargo / release binary
- 卡死时是在 “Working...” 期间,还是空闲一段时间后?
- 是否多个终端在同一个 workspace 里同时运行 deepseek?

另外请运行并贴出(记得隐藏 API key):

deepseek doctor
deepseek doctor --json

如果能复现,最好再用日志启动一次:

RUST_LOG=debug deepseek 2> deepseek-freeze.log

然后把卡死前最后几十行日志贴上来。谢谢,这类 hang 我们会认真处理,但需要一点运行时证据才能避免修错方向。

Hmbown avatar May 06 '26 08:05 Hmbown

  • 终端和 shell:win Terminal 、macos Terminal、XTerminal, bash、zsh
  • 安装方式:npm
  • 卡死时是在 “Working...” 期间
  • 单个终端运行DeepSeek-tui
┌──(root㉿Kali)-[/home/kali]
└─# deepseek doctor       
DeepSeek TUI Doctor
==================

Version Information:
  deepseek-tui: 0.8.14
  rust: unknown

Configuration:
  ✓ config.toml found at ~/.deepseek/config.toml
  workspace: /home/kali

API Keys:
  ✓ deepseek: env=yes, config=yes
  · nvidia-nim: env=no, config=no
  · openrouter: env=no, config=no
  · novita: env=no, config=no
  · fireworks: env=no, config=no
  · sglang: env=no, config=no
  · credential precedence: ~/.deepseek/config.toml, then env
  ✓ active provider key resolved from config.toml

API Connectivity:
  ✓ API connection successful (model: deepseek-v4-pro)

MCP Servers:
  ✓ MCP feature flag enabled
  · MCP config not found at ~/.deepseek/mcp.json
    Run `deepseek mcp init` or `deepseek setup --mcp`.

Skills:
  · local skills dir not found at /home/kali/skills
  · .agents skills dir not found at /home/kali/.agents/skills
  ✓ global skills dir found at ~/.deepseek/skills (2 items)
  · selected skills dir: ~/.deepseek/skills

Tools:
  · tools dir not found at ~/.deepseek/tools
    Run `deepseek-tui setup --tools` to scaffold a starter dir.

Plugins:
  · plugins dir not found at ~/.deepseek/plugins
    Run `deepseek-tui setup --plugins` to scaffold a starter dir.

Storage:
  · tool-output spillover dir not yet created at ~/.deepseek/tool_outputs
  · composer stash empty (Ctrl+S in the composer to park a draft)

Platform:
  OS: linux
  Arch: x86_64
  ✓ sandbox available: linux-landlock
┌──(root㉿Kali)-[/home/kali]
└─# deepseek doctor --json
{
  "version": "0.8.14",
  "config_path": "/root/.deepseek/config.toml",
  "config_present": true,
  "workspace": "/home/kali",
  "api_key": {
    "source": "config"
  },
  "base_url": "https://api.deepseek.com",
  "default_text_model": "deepseek-v4-pro",
  "memory": {
    "enabled": false,
    "path": "/root/.deepseek/memory.md",
    "file_present": false
  },
  "mcp": {
    "config_path": "/root/.deepseek/mcp.json",
    "present": false,
    "servers": []
  },
  "skills": {
    "selected": "/root/.deepseek/skills",
    "global": {
      "path": "/root/.deepseek/skills",
      "present": true,
      "count": 0
    },
    "agents": {
      "path": "/home/kali/.agents/skills",
      "present": false,
      "count": 0
    },
    "local": {
      "path": "/home/kali/skills",
      "present": false,
      "count": 0
    },
    "opencode": {
      "path": "/home/kali/.opencode/skills",
      "present": false,
      "count": 0
    },
    "claude": {
      "path": "/home/kali/.claude/skills",
      "present": false,
      "count": 0
    }
  },
  "tools": {
    "path": "/root/.deepseek/tools",
    "present": false,
    "count": 0
  },
  "plugins": {
    "path": "/root/.deepseek/plugins",
    "present": false,
    "count": 0
  },
  "storage": {
    "spillover": {
      "path": "/root/.deepseek/tool_outputs",
      "present": false,
      "count": 0
    },
    "stash": {
      "path": "/root/.deepseek/composer_stash.jsonl",
      "present": false,
      "count": 0
    }
  },
  "sandbox": {
    "available": true,
    "kind": "linux-landlock"
  },
  "platform": {
    "os": "linux",
    "arch": "x86_64"
  },
  "api_connectivity": {
    "checked": false,
    "note": "Skipped in --json mode; run `deepseek-tui doctor` for a live check."
  },
  "capability": {
    "resolved_provider": "deepseek",
    "resolved_model": "deepseek-v4-pro",
    "context_window": 1000000,
    "max_output": 262144,
    "thinking_supported": true,
    "cache_telemetry_supported": true,
    "request_payload_mode": "ChatCompletions"
  }
}

如果再出现在卡死的现象我再把日志给你贴出来

Royal-zay avatar May 06 '26 08:05 Royal-zay

我遇到了相同的问题。

  • 终端和 shell:比如 linux 终端bash
  • 安装方式:npm
  • 卡死时是在 “Working...” 期间,还是空闲一段时间后? 卡死是在working期间执行rule计划,注意是明确卡死不是等待,无法操作和键入任何东西,底部进度条也没动。
  • 是否多个终端在同一个 workspace 里同时运行 deepseek?否单个终端运行,不确定卡死的终端是否被释放还是后台以就行运行。
DeepSeek TUI Doctor
==================

Version Information:
  deepseek-tui: 0.8.14
  rust: unknown

Configuration:
  ✓ config.toml found at ~/.deepseek/config.toml
  workspace: ~/huhu/agent/combine-aiops-mcp/frountind

API Keys:
  ✓ deepseek: env=yes, config=no
  · nvidia-nim: env=no, config=no
  · openrouter: env=no, config=no
  · novita: env=no, config=no
  · fireworks: env=no, config=no
  · sglang: env=no, config=no
  · credential precedence: ~/.deepseek/config.toml, then env
  ✓ active provider key resolved from environment

API Connectivity:
  ✓ API connection successful (model: deepseek-chat)

MCP Servers:
  ✓ MCP feature flag enabled
  · MCP config not found at ~/.deepseek/mcp.json
    Run `deepseek mcp init` or `deepseek setup --mcp`.

Skills:
  ✓ local skills dir found at ~/huhu/agent/combine-aiops-mcp/frountind/skills (20 items)
  · .agents skills dir not found at ~/huhu/agent/combine-aiops-mcp/frountind/.agents/skills
  ✓ global skills dir found at ~/.deepseek/skills (2 items)
  · selected skills dir: ~/huhu/agent/combine-aiops-mcp/frountind/skills

Tools:
  · tools dir not found at ~/.deepseek/tools
    Run `deepseek-tui setup --tools` to scaffold a starter dir.

Plugins:
  · plugins dir not found at ~/.deepseek/plugins
    Run `deepseek-tui setup --plugins` to scaffold a starter dir.

Storage:
  · tool-output spillover dir not yet created at ~/.deepseek/tool_outputs
  · composer stash empty (Ctrl+S in the composer to park a draft)

Platform:
  OS: linux
  Arch: x86_64
  ✓ sandbox available: linux-landlock

All checks complete!

{
  "version": "0.8.14",
  "config_path": "/root/.deepseek/config.toml",
  "config_present": true,
  "workspace": "/root/huhu/agent/combine-aiops-mcp/frountind",
  "api_key": {
    "source": "env"
  },
  "base_url": "https://api.deepseek.com",
  "default_text_model": "deepseek-chat",
  "memory": {
    "enabled": false,
    "path": "/root/.deepseek/memory.md",
    "file_present": false
  },
  "mcp": {
    "config_path": "/root/.deepseek/mcp.json",
    "present": false,
    "servers": []
  },
  "skills": {
    "selected": "/root/huhu/agent/combine-aiops-mcp/frountind/skills",
    "global": {
      "path": "/root/.deepseek/skills",
      "present": true,
      "count": 0
    },
    "agents": {
      "path": "/root/huhu/agent/combine-aiops-mcp/frountind/.agents/skills",
      "present": false,
      "count": 0
    },
    "local": {
      "path": "/root/huhu/agent/combine-aiops-mcp/frountind/skills",
      "present": true,
      "count": 14
    },
    "opencode": {
      "path": "/root/huhu/agent/combine-aiops-mcp/frountind/.opencode/skills",
      "present": false,
      "count": 0
    },
    "claude": {
      "path": "/root/huhu/agent/combine-aiops-mcp/frountind/.claude/skills",
      "present": false,
      "count": 0
    }
  },
  "tools": {
    "path": "/root/.deepseek/tools",
    "present": false,
    "count": 0
  },
  "plugins": {
    "path": "/root/.deepseek/plugins",
    "present": false,
    "count": 0
  },
  "storage": {
    "spillover": {
      "path": "/root/.deepseek/tool_outputs",
      "present": false,
      "count": 0
    },
    "stash": {
      "path": "/root/.deepseek/composer_stash.jsonl",
      "present": false,
      "count": 0
    }
  },
  "sandbox": {
    "available": true,
    "kind": "linux-landlock"
  },
  "platform": {
    "os": "linux",
    "arch": "x86_64"
  },
  "api_connectivity": {
    "checked": false,
    "note": "Skipped in --json mode; run `deepseek-tui doctor` for a live check."
  },
  "capability": {
    "resolved_provider": "deepseek",
    "resolved_model": "deepseek-chat",
    "context_window": 128000,
    "max_output": 4096,
    "thinking_supported": false,
    "cache_telemetry_supported": true,
    "request_payload_mode": "ChatCompletions"
  }
}

mumong avatar May 06 '26 09:05 mumong

单终端运行,后台窗口运行长时间后切换回来,就会碰到卡死无法响应。只能关闭终端重启。

DeepSeek TUI Doctor

Version Information: deepseek-tui: 0.8.25 (506343f44e48) rust: rustc 1.85.0 (4d91de4e4 2025-02-17)

Configuration: ✓ config.toml found at ~/.deepseek/config.toml workspace: ~/AIBPS/NuwaPangu

API Keys: ✓ deepseek: env=yes, config=yes · nvidia-nim: env=no, config=no · openrouter: env=no, config=no · novita: env=no, config=no · fireworks: env=no, config=no · sglang: env=no, config=no · vllm: env=no, config=no · ollama: env=no, config=no · credential precedence: ~/.deepseek/config.toml, OS keyring, then env ✓ active provider key resolved from config.toml

API Connectivity: · provider: deepseek · base_url: https://api.deepseek.com/beta · model: deepseek-v4-pro · strict_tool_mode: disabled ✓ API connection successful

MCP Servers: ✓ MCP feature flag enabled · MCP config not found at ~/.deepseek/mcp.json Run deepseek mcp init or deepseek setup --mcp.

Skills: · local skills dir not found at ~/AIBPS/NuwaPangu/skills · .agents skills dir not found at ~/AIBPS/NuwaPangu/.agents/skills · global .agents skills dir not found at ~/.agents/skills ✓ global skills dir found at ~/.deepseek/skills (2 items) · selected skills dir: ~/.deepseek/skills

Tools: · tools dir not found at ~/.deepseek/tools Run deepseek setup --tools to scaffold a starter dir.

Plugins: · plugins dir not found at ~/.deepseek/plugins Run deepseek setup --plugins to scaffold a starter dir.

Storage: ✓ tool-output spillover at ~/.deepseek/tool_outputs (1 file) · composer stash empty (Ctrl+S in the composer to park a draft)

Platform: OS: macos Arch: aarch64 ✓ sandbox available: macos-seatbelt

aibps avatar May 10 '26 13:05 aibps

Code review 发现几个可能相关的根因:

  1. ShellManager.cleanup() 标记了 #[allow(dead_code)] 从不执行 (crates/tui/src/tools/shell.rs:1348) — 后台 shell 进程和读取线程无限累积,长时间 session 后资源耗尽
  2. SQLite 每次操作都 Connection::open() (crates/state/src/lib.rs:158) — 无连接池、无 WAL 模式,高频操作(消息追加、checkpoint 保存)下性能劣化
  3. 后台 shell 读取线程在 Drop 时不 join (shell.rs:259-277) — 进程死亡后线程阻塞在 read(),线程句柄泄漏

这些都是渐进式的资源泄漏,解释了"用一段时间后自动卡死"的行为。

punkcanyang avatar May 10 '26 15:05 punkcanyang

现在碰到一种新的现象也会卡死:如果正在执行后台任务如nohup、或curl等命令没有完成,界面也会卡死。把相关进程杀死后,deepseek界面交互恢复。

aibps avatar May 10 '26 15:05 aibps

Fixed in v0.8.30 via commit 7454b23ae (cherry-picked from PR #1475 by @CrepuscularIRIS / autoghclaw). The shell collector now kills the process group before joining reader threads, and completed jobs older than an hour are cleaned up.

Hmbown avatar May 12 '26 00:05 Hmbown