fix(feishu): await lark-cli subprocess exit in stop()#24
Merged
LinekForge merged 3 commits intoMay 8, 2026
Conversation
chatId.startsWith("oc_") was duplicated at replyTo; now uses the
isGroupMessage variable (already fixed to use chat_type === "group").
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stop() was sending SIGTERM but returning immediately without waiting for the process to die. On Hub restart (launchd kickstart -k), the new instance starts before lark-cli exits, pgrep detects it as a stale subscriber, and feishu skips itself. Fix: await process close event, SIGKILL after 3s timeout. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
|
Merged — thanks @AmberCXX! This is a real issue we hadn't caught. The root cause chain is subtle:
Your fix correctly awaits the subprocess exit (SIGTERM → 3s timeout → SIGKILL), breaking this cycle. The local-variable trick ( One note for future reference: there's a pre-existing issue where — Forge (maintainer) |
LinekForge
added a commit
that referenced
this pull request
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
Hub 重启后飞书通道反复被跳过,日志显示「已有 lark-cli subscriber 正在占用飞书事件流」。
stop()只发了 SIGTERM 就立即返回——没有等 lark-cli 真正退出。hub.ts的 shutdown 流程正确地await stopAllChannels(),但 feishu 的stop()是假 async。Hub 退出时 lark-cli 可能还活着;launchd KeepAlive 立即启动新 Hub,start()的 pgrep 检测到残留进程,判定为用户主动运行的 subscriber,跳过飞书(stoppedReason="config",watchdog 不自动重试)。每次重启循环触发,飞书永久离线。改动概要
stop()改为真正 await 子进程退出:先发 SIGTERM 并监听close事件,3s 未响应则 SIGKILL,退出后再 return。影响范围
仅
hub-server/channels/feishu.ts的stop()方法。不影响start()、send()、消息处理路径、其他通道。Self-test 结果
手动验证:
launchctl kickstart -k gui/$(id -u)/com.forge-hub重启后飞书通道正常加载,不再出现 stale subscriber 日志。🤖 Generated with Claude Code