( connection: SseConnection, reason: CloseReason, maxQueueSize: number, )
| 168 | }; |
| 169 | |
| 170 | const closeConnection = ( |
| 171 | connection: SseConnection, |
| 172 | reason: CloseReason, |
| 173 | maxQueueSize: number, |
| 174 | ): void => { |
| 175 | if (connection.closed) return; |
| 176 | connection.closed = true; |
| 177 | activeSse.delete(connection.id); |
| 178 | const now = Date.now(); |
| 179 | console.log( |
| 180 | `${LOG_PREFIX} ${JSON.stringify({ |
| 181 | event: "sse_close", |
| 182 | connectionId: connection.id, |
| 183 | reason, |
| 184 | ageMs: now - connection.startedAt, |
| 185 | bytesForwarded: connection.bytes, |
| 186 | chunksForwarded: connection.chunks, |
| 187 | lastWriteAgeMs: now - connection.lastWriteAt, |
| 188 | colo: connection.colo, |
| 189 | scriptVersion: connection.scriptVersion, |
| 190 | })}`, |
| 191 | ); |
| 192 | maybeEmitPeriodicSnapshot(now, maxQueueSize); |
| 193 | }; |
| 194 | |
| 195 | const sseHeaders = (headers: Headers): Headers => { |
| 196 | const next = new Headers(headers); |
no test coverage detected