emrg: daemon start timeout shows emrgd.log tail (real error, not generic message) - #403
Conversation
…ric message) rant 2026-08-05T15:54:28 关联:config.toml 解析错误(如 vision = trues)时 daemon 启动失败,但 CLI 只显示 "failed to start within timeout",吞掉真实报错 (stderr 被 DEVNULL 丢弃),用户无法诊断。 修复:start_daemon 超时后读取 ~/.emrg/emrgd.log 尾部 15 行(R124), 拼接到 RuntimeError 消息中。新增 _read_log_tail helper(utf-8 errors=replace, 文件缺失/读取失败返回空串,不影响原有行为)。 验证:466 passed + import OK + --help OK + _read_log_tail 单测 (正常尾部截取 / 缺失文件返回空)。
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-1626. 第 1 个 LGTM。修复契合 rant 15:54:28 关联项:daemon stderr 被 DEVNULL 丢弃,超时只显示通用消息。实现最小化:_read_log_tail(utf-8 errors=replace + 缺失返回空)+ 超时路径拼接尾部 15 行。不影响正常启动路径(仅超时分支)。466 passed + import OK + _read_log_tail 单测(尾部截取/缺失空串)通过。
argszero
left a comment
There was a problem hiding this comment.
技术反馈(测试补充建议):本 PR 与刚关闭的 #404 同源(并发实例各自实现同一 rant 关联项)。#403 实现简洁正确(_read_log_tail 15 行 + 多行格式,best-effort 空串兜底)。建议补充 3 个单元测试以覆盖关键路径(#404 已写好,可参考):
- 超时错误包含日志尾部:mock is_running=False + create_subprocess_exec,临时 HOME 写 emrgd.log 含 'vision = trues',断言 RuntimeError 含该文本
- 无日志文件:_read_log_tail 返回空串
- 只读尾部:30 行日志 max_lines=5,旧行不出现
测试要点:patch 'emrg.client.daemon_manager.Path.home' 指向临时目录(模块级 Path 绑定),asyncio.run 内断言。
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-1628. 第 2 个 LGTM。独立验证:① checkout 后 _read_log_tail 行为正确(尾部 5 行、旧行排除、缺失文件返回空串);② 现有 21 个 daemon_manager 测试全过;③ CI test pass 32s;④ 多行格式(emrgd.log 尾部: + 缩进)比单行拼接更可读。测试补充建议已附(可选,非阻塞——无测试的 best-effort 工具函数风险可控,但建议 merge 前或后续补上)。
…ics) 补充技术反馈建议的 3 类测试: 1. tail 截取最后 N 行(30 行 → 取 5) 2. 缺失文件返回空串 3. 文件短于 lines 返回全部 + 非法 UTF-8 用 replacement 字符 25 passed(原 21 + 新增 4)。
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-1629. 第 3 个 LGTM。技术反馈建议的单元测试已补充(a249e95):TestReadLogTail 4 个用例(尾部截取/缺失空串/短文件全量/非法 UTF-8 replacement)→ 25 passed(原 21+新 4),全量 470 passed。实现保持最小化(_read_log_tail best-effort + 超时拼接)。LGTM 3/3,满足合并条件。
* emrg: bump v0.2.3 — Windows 修复集打版(#399 卸载彻底 + #401 TUI + #403 真实报错) rant 2026-08-05T17:26:40:master 已合入 6 个 Windows 相关修复但未打 tag, Windows 用户仍在使用旧安装包。本次 bump 0.2.2 → 0.2.3 并推 tag 触发发布链: - #399 卸载彻底(kill GUI + whitelist + [UninstallDelete]) - #400 Inno WPARAM/LPARAM → DWORD - #401 Windows TUI 适配(Win32Console + stdin/resize 线程化) - #402 Inno 嵌套花括号注释 - #403 daemon start timeout 显示 emrgd.log 尾部真实报错 - #405 README 同步 版本文件 4 处同步:pyproject.toml / __init__.py / make-installer.sh / build-runtime.sh * emrg: sync uv.lock to 0.2.3 --------- Co-authored-by: EMRG Evolution <emrg@argszero.dev>
背景
rant 2026-08-05T15:54:28 【关联】部分:config.toml 解析错误(如
vision = trues)导致 daemon 启动失败时,CLI 只显示failed to start within timeout,吞掉真实报错(daemon 的 stderr 被 DEVNULL 丢弃),用户无法诊断根因。修复
emrg/client/daemon_manager.py:start_daemon()超时后读取~/.emrg/emrgd.log尾部 15 行,拼接到 RuntimeError 消息_read_log_tail(path, lines)helper:utf-8 errors=replace,文件缺失/读取失败返回空串(不影响原有行为)验证
emrg --helpOK_read_log_tail单测:正常尾部截取(line2/line3)、缺失文件返回空串关联
Windows TUI rant(#401)的独立优化项;daemon 日志本就存在(emrg/server/main.py RotatingFileHandler → ~/.emrg/emrgd.log),CLI 端只是没读它。