mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
* fix(mattermost): add WebSocket reconnection with exponential backoff Fixes #13980 The Mattermost WebSocket monitor had no error handling around the reconnection loop. When connectOnce() threw (e.g. 'fetch failed' from network issues), the error propagated through the while loop, causing the gateway to log 'channel exited' and never restart. Extract runWithReconnect() utility that: - Catches thrown errors from connectFn and retries - Uses exponential backoff (2s→4s→8s→...→60s cap) - Resets backoff after successful connections - Stops cleanly on abort signal - Reports errors and reconnect delays via callbacks * fix(mattermost): make backoff sleep abort-aware and reject on WS connect failure * fix(mattermost): clean up abort listener on normal timeout to prevent leak * fix(mattermost): skip error reporting when abort causes connection rejection * fix(mattermost): use try/finally for abort listener cleanup in connectOnce * fix: force-close WebSocket on error to prevent reconnect hang * fix: use ws.terminate() on abort for reliable teardown during CONNECTING state * fix(mattermost): use initial retry delay for reconnect backoff --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>