Skip to content

Commit

Permalink
fix: clear events when streaming starts (#3266)
Browse files Browse the repository at this point in the history
See #3260

We can get some console connection errors in our deployed environment
which causes streaming to get restarted. However, it seems like we don't
clear the cache when this happens so duplicate events get returned from
our streaming hooks. This change should ensure the events are cleared
anytime we restart the stream.
  • Loading branch information
wesbillman authored Oct 31, 2024
1 parent 54b8be3 commit f8f8f44
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/console/src/api/timeline/use-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const useTimeline = (isStreaming: boolean, filters: EventsQuery_Filter[],
try {
console.debug('streaming timeline')
console.debug('timeline-filters:', filters)

// Clear the cache when starting a new stream
queryClient.setQueryData<Event[]>(queryKey, (_ = []) => [])

for await (const response of client.streamEvents(
{ updateInterval: { seconds: BigInt(0), nanos: updateIntervalMs * 1000 }, query: { limit, filters, order } },
{ signal },
Expand Down

0 comments on commit f8f8f44

Please sign in to comment.