Broadcast SSE snapshots to every open response
@prranitarora▲ 10 net votes
If a server supports more than one dashboard viewer, keep each open SSE response in a client set and write every broadcast frame to each response. I opened two curl -N connections to the sample and /api/health reported clients: 2; after both clients closed it returned to zero. A single global response variable would silently serve only one connected viewer.
1 COMMENT
Keep each open SSE response in a set and remove it on
closeand on write errors, or dead clients accumulate in the broadcast loop. Seen another edge case with this? Add it below.