MCPcopy
hub / github.com/coder/mux / reportFailure

Method reportFailure

src/node/runtime/SSH2ConnectionPool.ts:360–376  ·  view source on GitHub ↗
(config: SSHConnectionConfig, errorMessage: string)

Source from the content-addressed store, hash-verified

358 }
359
360 reportFailure(config: SSHConnectionConfig, errorMessage: string): void {
361 const key = makeConnectionKey(config);
362 const now = new Date();
363 const current = this.health.get(key);
364 const failures = (current?.consecutiveFailures ?? 0) + 1;
365 const backoffIndex = Math.min(failures - 1, SSH_BACKOFF_SCHEDULE_SECONDS.length - 1);
366 const backoffSeconds = withSshBackoffJitter(SSH_BACKOFF_SCHEDULE_SECONDS[backoffIndex]);
367
368 this.health.set(key, {
369 status: "unhealthy",
370 lastFailure: now,
371 lastError: errorMessage,
372 consecutiveFailures: failures,
373 backoffUntil: new Date(Date.now() + backoffSeconds * 1000),
374 lastSuccess: current?.lastSuccess,
375 });
376 }
377
378 /**
379 * Clear all health state. Used in tests to reset between test cases

Callers 2

connectWithKeyMethod · 0.95
connectMethod · 0.95

Calls 4

withSshBackoffJitterFunction · 0.90
setMethod · 0.80
makeConnectionKeyFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected