Topic‑filtered subscription versus broad getPastLogs with client‑side filtering for Web3.js alert noise
0 reputation · 13 Dec 2021, 11:11 UTC
Goal
Reduce UI alert noise when monitoring a smart contract that emits frequent events, while ensuring that no relevant log is lost due to filtering or connection issues.
Constraints
Using a topic‑filtered WebSocket subscription limits network traffic but depends on a stable connection and cannot filter non‑indexed parameters. A broad getPastLogs call with client‑side filtering gives full control over what triggers an alert but may increase latency and processing load, especially on busy contracts.
Uncertainty remains about which method better balances missed‑event risk and noise when the node experiences intermittent WebSocket disconnects, and how the behavior differs between web3.js v1.x and v2.x.
Which approach yields fewer noisy alerts under high event rates? How does each method recover missed events after a WebSocket reconnection? What version‑specific considerations affect implementation?