kitty-items
kitty-items copied to clipboard
Use a safer approach to event tracking
Describe the bug The code for event tracking here https://github.com/onflow/kitty-items/blob/e2255bce7ff5f34fca242374489d3601d0ba3daf/api/src/workers/base-event-handler.ts#L41-L44
works fine when connecting to a single AN, but can be unsafe when using a proxy with many ANs behind it like what we recommend for FCL. The problem is that sometimes an Access node will fall behind, resulting in this tracker reprocessing events from past blocks.
To Reproduce
It is hard to force this, but if one of the Access nodes behind a proxy falls behind (it reboots, or is shutdown), and that node is selected for the call to getLatestBlockHeight, the range will be reset potentially thousands of blocks into the past, causing this logic to re-ingest all of the events.
Expected behavior The event processor should ignore past blocks.
This really only matters as this is an example implementation many new devs may copy, it's it best to demonstrate how to avoid this somewhat common pitfall.
What is the safer approach?
closing because we are archiving in favor of the flow app quickstart