feat(core-backend): add debouncer system notifications in AccountActivity - #9700
feat(core-backend): add debouncer system notifications in AccountActivity#9700Kriys94 wants to merge 1 commit into
Conversation
b6333f9 to
0068c48
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0068c48. Configure here.
| clearTimeout(this.#statusChangeDebouncer.timer); | ||
| this.#statusChangeDebouncer.timer = null; | ||
| } | ||
| this.#statusChangeDebouncer.pendingChanges.clear(); |
There was a problem hiding this comment.
Disconnect drops pending chain downs
High Severity
#chainsUp is updated immediately on each system notification, but statusChanged is only published after the debounce window. On disconnect, buffered changes are cleared and only remaining #chainsUp entries are marked down. Chains that flipped to down inside the window are already removed from #chainsUp, so their pending down is discarded and never published. Consumers such as TokenBalancesController can keep treating those chains as up (slow websocket polling) through an outage, when downs and disconnects often arrive together.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0068c48. Configure here.


Explanation
Without Debouncer: https://www.loom.com/share/e96ef8f592254e9baaad15e86e823fa4
With Debouncer: https://www.loom.com/share/eddb747eb72b4a6eb8e880e9a942ac12
References
Checklist
Note
Medium Risk
Changes real-time chain status signaling timing and payload shape for downstream listeners (e.g. polling coordination); disconnect path behavior is intentionally altered to drop pending ups.
Overview
AccountActivityServiceno longer publishesAccountActivityService:statusChangedon every system notification. Incoming chain up/down updates are buffered per chain, the flush timer resets on each notification (1s base + up to 1s random jitter), and flush emits at most one batched event per status (upanddownseparately) with mergedchainIds. Debounced publishes no longer includetimestamp(disconnect-drivendownevents still can).Pending buffers and timers are cleared on WebSocket disconnect (so stale
upevents are not emitted after a disconnectdownflush) and cancelled indestroy(). Changelog documents the behavior change; tests use fake timers for batching, timer reset, jitter, disconnect, and destroy.Reviewed by Cursor Bugbot for commit 0068c48. Bugbot is set up for automated code reviews on this repo. Configure here.