fix(gateway): give Feishu a 90s first-connect budget - #85595
Conversation
Cold lark_oapi import (~24s) plus the websocket handshake exceeds the 30s platform isolation timeout, so the first connect after update always fails and the bot stays offline if the process is restarted before retry. Fixes NousResearch#85564
|
Thanks — this matches my report exactly, and it fixes the issue for me. Concrete data point: on my machine (Windows 11, lark-oapi 1.6.8) the cold connect with One note for the release notes: users who already set |
|
Thanks for the timing on Windows — 33s cold with a 60s cap matches the original report. Confirmed the precedence: |
fix(gateway): give Feishu a 90s first-connect budget
|
|
@C:/Users/admin/AppData/Local/Temp/opencode/review-85595.md |
What breaks
After
hermes update, Feishu often comes up as:A later in-process retry connects in ~1s. If the updater restarts the gateway process before that retry, there is no cache and the bot stays offline until someone restarts it by hand. Users see “Feishu stopped after update”.
Why
Two stacked changes:
getUpdateson first connect).lark_oapiwas deferred intoconnect()viaasyncio.to_thread(_load_lark_oapi)so an unused Feishu extra does not pay ~24s at import. The SDK is ~49MB / 10k+ modules. Measured cold import on the reporter’s box: 24.3s. Import + websocket handshake > 30s every cold boot.Once the module is in
sys.modules, retry is ~1s. The 30s bound is only fatal on the first connect of a fresh process — exactly the post-update path.gateway.platform_connect_timeout: 60already unblocks this (reporter: first connect at 33s). There was no Feishu-specific default.What this changes
GatewayRunner._platform_connect_timeout_secs(Platform.FEISHU)is 90s, same idea as Telegram’s extra budget.HERMES_GATEWAY_PLATFORM_CONNECT_TIMEOUTandgateway.platform_connect_timeoutstill win over that default. If you already set60as the #19776 escape hatch, first connect stays capped at 60s after this lands — drop the override to get the 90s budget. Reporter follow-up: Windows 11 / lark-oapi 1.6.8 cold connect ~33s with that 60s cap.The lazy import is left in place: we do not pull
lark_oapiback to module scope (that was #57657 / #68756).Verify
Existing lazy-import tests still assert the SDK is not loaded at config time. Not re-timed against a real Feishu tenant on this machine.
Fixes #85564