MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / closeConnection

Function closeConnection

apps/cloud/src/observability/memory-metrics.ts:170–193  ·  view source on GitHub ↗
(
  connection: SseConnection,
  reason: CloseReason,
  maxQueueSize: number,
)

Source from the content-addressed store, hash-verified

168};
169
170const 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
195const sseHeaders = (headers: Headers): Headers => {
196 const next = new Headers(headers);

Callers 2

flushFunction · 0.70
cancelFunction · 0.70

Calls 3

logMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected