Skip to content

Conversation

@raulrpearson
Copy link
Contributor

Problem

When listing and paginating events in the event live views, we sometimes get a duplicate IDs error like this:

found duplicate ID "event-123" for component ClaperWeb.EventLive.EventCardComponent when rendering template

This could happen in several ways, but one of them that I could reproduce easily is by listing events on a tab, then creating an event on a new tab, then loading the second page of events on the first tab:

duplicate-event-id.mp4

This happens because the original view becomes stale and because we use offset-limit pagination, the second page loads an event that was already on the stale version of the first page. A duplicate ID runtime exception is triggered in this case, but the app would also currently silently fail by missing one event on "load more" if an event was deleted from the top of the list (on a different tab). Similar scenarios could happen when an event is terminated, for example, because the event moves from one list to another.

Solutions

There's a few things that we could improve in general with this part of the app:

  • Implement keyset pagination. This would avoid these intrinsic problems with offset pagination.
  • Implement a more comprehensive set of PubSub messages to avoid having stale views.
  • Refactor events list as a stream. This would just make it more memory efficient.

This PR currently expands and lightly refactors the user events PubSub subscription and broadcasting, refreshing the list of events. This prevents the duplicate ID problem but also makes the UI more responsive to changes.

@alxlion, happy to change the approach or rewrite the PR, let me know what you think. There's many other things that I'm tempted to suggest we change, but I'm trying to keep refactors to a sensible minimum.

Testing

Aside from running mix test, I manually opened up a couple of tabs for two different users and I tested creating, updating and deleting events to make sure that views would refresh correctly.

@raulrpearson raulrpearson force-pushed the fix-event-live-duplicates branch from e226ea6 to 3919367 Compare November 20, 2025 19:17
@raulrpearson
Copy link
Contributor Author

@alxlion, I just rebased on top of the latest dev in order to resolve a small conflict. I also tested creating an event with a presentation and was able to reproduce the duplicate event ID runtime error I mentioned in #190. I'm marking the PR as draft again and will open up for review once I've addressed that scenario as well.

@raulrpearson raulrpearson marked this pull request as draft November 20, 2025 19:25
@raulrpearson
Copy link
Contributor Author

Seems to work now (after some small changes). I tested creating, updating, sharing, unsharing and deleting events in a few open tabs at the same time and broadcasting/subscriptions seem to work smoothly and no duplicate event ID errors triggered. Let me know what you think.

@raulrpearson raulrpearson marked this pull request as ready for review November 21, 2025 18:12
@alxlion
Copy link
Contributor

alxlion commented Dec 4, 2025

Perfect! As you know, this page isn't "real-time critical", the most important thing was to remove those errors. Thanks for your work 😉

@alxlion alxlion merged commit 3b511bc into ClaperCo:dev Dec 4, 2025
1 check passed
@raulrpearson raulrpearson deleted the fix-event-live-duplicates branch December 4, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants