WeKnora/internal/im/wecom
wizardchen c8d6e2103b fix(im/wecom): scope connection close to its own generation
The heartbeat loop and the detached callback handlers close the client's
current connection, but their goroutines can outlive the connection that
spawned them: heartbeatCancel only signals, and callback handlers run on a
context deliberately detached from the connection. A late-firing goroutine
therefore closed whatever connection the reconnect loop had just opened,
leaving the client to drop messages until the next read timeout.

Pass the owning connection into both callers and close through closeConnIf,
which only acts while that connection is still active. This matches the
yunzhijia and qqbot drivers, which already scope their heartbeat loops to a
single connection.

Also fold Stop() into closeConn so it no longer holds c.mu across Close.
Stop() was the one caller where the delay actually spread: the IM service
tears channels down while holding its channel-map lock, so a TLS close_notify
write to a stalled peer stalled every other channel operation.

The receive loop's deferred cleanup now closes only through closeConnIf,
dropping a redundant second Close of the same connection, and connectAndRun
re-checks the closed flag after publishing the connection so a Stop() racing
the dial cannot leave a receive loop running until its read deadline expires.
2026-08-06 12:26:00 +08:00
..
factory.go fix(im): harden connection lifecycle across replicas 2026-07-27 20:39:12 +08:00
longconn.go fix(im/wecom): scope connection close to its own generation 2026-08-06 12:26:00 +08:00
longconn_close_test.go fix(im/wecom): scope connection close to its own generation 2026-08-06 12:26:00 +08:00
mention_test.go feat(im): support custom endpoints for private WeCom deployments 2026-04-13 22:54:42 +08:00
quote.go fix(im): anti-hallucination for non-text quotes and unprocessable media messages 2026-04-03 11:34:22 +08:00
quote_test.go fix(im): anti-hallucination for non-text quotes and unprocessable media messages 2026-04-03 11:34:22 +08:00
reconnect_test.go fix(im): clamp reconnect backoff to avoid int64 overflow → busy loop 2026-05-05 00:36:18 +08:00
webhook_adapter.go feat(im): support custom endpoints for private WeCom deployments 2026-04-13 22:54:42 +08:00
ws_adapter.go feat(im): align agent stream display with web thinking and tool progress 2026-06-24 10:33:55 +08:00