Repository navigation
fix(dispatch): 群成员实时查询超时时提示可调大 BOTMUX_LARK_LIST_BOTS_API_TIMEOUT_MS - #3012
Merged
Merged
Conversation
现象:dispatch --bot-app 建立协作身份前实时查询群内 Bot 成员(/members/bots 与 is_in_chat),在到飞书往返较慢的网络下超过 listBotsApiTimeoutMs(默认 3000ms)即失败退出,报错只有原始文本「list chat bot members timed out after 3000ms」,看不出这是可调的本地超时,也不知道该调哪个变量。 根因:promiseWithTimeout 超时时抛出的是普通 Error,listChatBotsViaMembersBots 与 resolveCurrentChatBotOpenIdsByLarkAppIds 只把它的文本拼进 reason/message,超时与飞书业务错误码、网络错误在结构上无法区分,dispatch 侧也就无从给出针对性提示。 修法:promiseWithTimeout 改为抛出带 timeoutMs 字段的 LarkCallTimeoutError(文本不变);成员查询失败结果在且仅在该错误类型时带上当时生效的 timeoutMs,resolveCurrentChatBotOpenIdsByLarkAppIds 的失败结果透传该字段;dispatch 仅在该字段存在时于原报错后追加一句:群成员实时查询超时、可调大环境变量 BOTMUX_LARK_LIST_BOTS_API_TIMEOUT_MS。仍然 fail-closed,不重试、不降级、不新增参数;业务错误码与其它异常的输出不变,bots list、send、授权与工作流等其它调用方只读原有字段,行为不变。 验证: - bunx vitest run --project unit test/dispatch-thread-id.test.ts test/list-chat-bot-members.test.ts test/exact-chat-grant.test.ts test/test-hygiene.test.ts test/bots-list-cred-registration.test.ts --maxWorkers=2:5 个文件 133 个用例全部通过;新增用例在修复前的代码上 2 个超时用例失败(输出只有 timed out after 20ms,不含变量名) - bunx tsc --noEmit -p tsconfig.json:通过 - bun run build:通过
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 10:48
…-timeout-hint-2008
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
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.
现象
botmux dispatch --bot-app在建立协作身份前会实时查询群内 Bot 成员(/members/bots与is_in_chat)。到飞书往返较慢时,查询超过listBotsApiTimeoutMs(默认 3000ms)即失败退出,报错只有一句原始文本:看不出这是可调的本地超时,也不知道该调哪个变量。
根因
promiseWithTimeout超时时抛的是普通Error,listChatBotsViaMembersBots与resolveCurrentChatBotOpenIdsByLarkAppIds只把它的文本拼进reason/message。超时与飞书业务错误码、网络错误在结构上无法区分,dispatch 也就给不出针对性的提示。修法
src/im/lark/client.ts:promiseWithTimeout改为抛带timeoutMs字段的LarkCallTimeoutError(不导出,错误文本与原来逐字一致)。成员查询的失败结果在且仅在该错误类型时带上当时生效的timeoutMs,/members/bots与is_in_chat两处都透传到resolveCurrentChatBotOpenIdsByLarkAppIds的失败结果(新增可选字段)。src/cli.ts:dispatch 只在该字段存在时,在原报错后追加一行:群成员实时查询在 3000ms 内未返回;网络较慢时可调大环境变量 BOTMUX_LARK_LIST_BOTS_API_TIMEOUT_MS(毫秒)后重试。判定看错误类型,不匹配文本。
影响面
promiseWithTimeout只有成员查询里的两处调用。listChatBotsViaMembersBots的其它调用方(bots list、建群、项目群、exact chat grant、sibling 解析)读到的reason/cacheable/ 错误文本都没变,只是多一个可选字段,bots list的失败缓存与兜底行为不变。resolveBotInChat等)只读ok/error/message/mappings,行为不变。验证
bunx vitest run --project unit test/dispatch-thread-id.test.ts test/list-chat-bot-members.test.ts test/exact-chat-grant.test.ts test/test-hygiene.test.ts test/bots-list-cred-registration.test.ts --maxWorkers=2:5 个文件 133 个用例通过。cmdDispatch和真实的严格解析器,只替换larkGet与本机 Bot 配置。... timed out after 20ms,不含变量名。timed out→232011用例变红(其 msg 故意带 "timed out");/members/bots或is_in_chat路径的timeoutMs透传 → 对应超时用例变红。bunx tsc --noEmit、bun run build通过。Fixes #2008