kitty-items icon indicating copy to clipboard operation
kitty-items copied to clipboard

Use a safer approach to event tracking

Open peterargue opened this issue 2 years ago • 1 comments
trafficstars

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.

peterargue avatar May 17 '23 19:05 peterargue

What is the safer approach?

10thfloor avatar Sep 08 '23 16:09 10thfloor

closing because we are archiving in favor of the flow app quickstart

joshuahannan avatar Jul 08 '24 16:07 joshuahannan