fix(edge): 恢复主运行 goroutine 与聚合器 panic,幂等 Bus.Close - #1735
Conversation
|
Warning Review limit reached
Next review available in: 16 minutes Limit details: You’ve used all 1 included review currently available under your plan. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
75009de to
3dc7c15
Compare
- lifecycle:把 run/watchRunProcess/publishOutput/publishStructuredOutput/cancelGrace/resultAggregator/resultAggregatorTimeout 全部裸 go 改走 safeGo,避免任一 panic 崩溃整个 Edge 进程 - events.Bus.Close:用 sync.Once 幂等化,二次调用不再 panic;新增 TestBusCloseIdempotent - finish:清理包级 hubCallbackQueues/hubStreamChunkSeq,避免 panic 路径跳过 fireHubDone/Fail 时条目泄漏 - hubCallbackQueueState.close:新增幂等 close 方法供 finish 与 terminal enqueue 共用 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
3dc7c15 to
779be27
Compare
背景
Edge 主
run()goroutine、output publish、watch、cancel grace、result aggregator 全部裸go,任一 panic(adapter parse、emitter chain、nil deref、类型断言失败)会崩溃整个 Edge 进程,所有在飞 run 被孤儿化、WS 客户端断连。pkg/safegodocstring 明确写「unguarded goroutine crashes the whole process」,但主执行链没有用。同时events.Bus.Close()非幂等(二次 close panic),finish()不清包级hubCallbackQueues/hubStreamChunkSeq,panic 路径泄漏条目。变更
edge-server/internal/lifecycle/:run/watchRunProcess/publishOutput/publishStructuredOutput/cancelGrace/resultAggregator/resultAggregatorTimeout全部裸go改走safeGo。run 的defer e.finish(run.ID)在 panic unwinding 期间仍执行(defers run before recover catches),terminal 状态与包级 map 卫生保留。edge-server/internal/events/bus.go:Bus.Close用sync.Once幂等化,二次调用返回 nil 不再 re-close stopCh panic。edge-server/internal/events/bus_behavior_test.go:删「NOT idempotent」注释,新增TestBusCloseIdempotent。edge-server/internal/lifecycle/process_executor_finish.go:finish()末尾LoadAndDeletehubCallbackQueues并closechannel,DeletehubStreamChunkSeq,避免 panic 路径跳过fireHubDone/fireHubFail时条目泄漏。sync.Map.Delete幂等,与 consumer defer 不冲突。edge-server/internal/lifecycle/process_executor_hub_callback.go:新增hubCallbackQueueState.close()幂等方法(mutex + closed flag),供finish与enqueueTerminalHubJob共用。证据
real_tested=false:单元测试覆盖 panic 恢复与幂等 close;未跑真实 agent CLI。go build ./...+go test ./internal/lifecycle/... ./internal/events/... -short -count=1+go test ./... -short -count=1(全绿)+go vet+gofmt -l(干净)+verify-ci-gates.py+verify-doc-ssot.py+git diff --check全绿。TestBusCloseIdempotent(二次 Close 不 panic)。关联
审计 P0-1(主 run goroutine 无 recover)+ P1-5(Bus.Close 非幂等)+ P2-7(包级 sync.Map 在 panic 路径泄漏)。