ContributingWeb client
Live updates
The server pushes each change through Server-Sent Events. Then the dashboard gets the changed data again.
The server sends a change event on the stream /api/v1/events.
1 / 4
Two kinds of streams
The server pushes data with Server-Sent Events: the log streams, and the change feed /api/v1/events.
The app reads them with fetch() and a parser for streams, src/lib/api/sse.ts. The same cookie proves who you are.
The change feed
src/lib/api/events.ts changes each change event into an invalidation of TanStack Query.
If the stream stops, the app connects again with an exponential backoff, from 1 to 15 seconds.
When the stream is down
While the stream is down, the queries use polling:
| Data | Interval |
|---|---|
| Lists | 5 seconds |
| The detail on screen | 2 to 3 seconds |
An older server has no change feed and answers 404. Then the queries also use polling.