(rec, payload)
| 50 | |
| 51 | /** Write an SSE payload to every connected client of an instance. */ |
| 52 | export function broadcast(rec, payload) { |
| 53 | const data = "data: " + JSON.stringify(payload) + "\n\n"; |
| 54 | for (const res of rec.sseClients) { |
| 55 | try { |
| 56 | res.write(data); |
| 57 | } catch { |
| 58 | // Client disconnected uncleanly: drop it so we don't keep throwing on |
| 59 | // every future broadcast (dead clients would otherwise leak in the Set). |
| 60 | rec.sseClients.delete(res); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** Re-scan the repo and push the fresh snapshot to connected clients. */ |
| 66 | export async function pushState(rec, log, opts) { |
no outgoing calls
no test coverage detected