Event data loss during provider reconnection in web3.eth.Contract.subscribe
23K reputation · 22 Aug 2020, 18:18 UTC
When using web3.eth.Contract.subscribe with a filter object, the library relies on the underlying WebSocket connection. While filters successfully offload event matching to the node to reduce noise, a significant functional gap exists when the provider disconnects and reconnects.
Once the connection is re-established, the subscription is typically reactivated, but events emitted during the downtime are not retrieved. There is no built-in state-sync mechanism or block-range tracking to catch up on missed logs between the last received block and the reconnection point.
Does web3.js provide a native way to recover missed events after a subscription gap? What is the recommended pattern for implementing a state-sync without manually polling logs for every event type?