mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
修复了4个严重的channel同步问题: 1. **parseCh无条件阻塞** (main.go:894-907) - 问题:cmd.Wait()先返回但parseJSONStreamWithLog永久阻塞时,主流程卡死 - 修复:引入ctxAwareReader和5秒drainTimer机制,Wait完成后立即关闭stdout 2. **context取消失效** (main.go:894-907) - 问题:waitCh先完成后不再监听ctx.Done(),取消信号被吞掉 - 修复:改为双channel循环持续监听waitCh/parseCh/ctx.Done()/drainTimer 3. **parseJSONStreamWithLog无读超时** (main.go:1056-1094) - 问题:bufio.Scanner阻塞读取,stdout未主动关闭时永远停在Read - 修复:ctxAwareReader支持CloseWithReason,Wait/ctx完成时主动关闭 4. **forceKillTimer生命周期过短** - 问题:waitCh返回后立刻停止timer,但stdout可能仍被写入 - 修复:统一管理timer生命周期,在循环结束后Stop和drain 5. **并发竞态修复** - main.go:492 runStartupCleanup使用WaitGroup同步 - logger.go:176 Flush加锁防止WaitGroup reuse panic **测试覆盖**: - 新增4个核心场景测试(Wait先返回、同时返回、Context超时、Parse阻塞) - main.go覆盖率从28.6%提升到90.32% - 154个测试全部通过,-race检测无警告 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
6 lines
63 B
Plaintext
6 lines
63 B
Plaintext
coverage.out
|
|
coverage*.out
|
|
cover.out
|
|
cover_*.out
|
|
coverage.html
|