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

Method markFailedByKey

src/node/runtime/sshConnectionPool.ts:425–443  ·  view source on GitHub ↗

* Mark connection as failed (internal use after failed probe)

(key: string, error: string)

Source from the content-addressed store, hash-verified

423 * Mark connection as failed (internal use after failed probe)
424 */
425 private markFailedByKey(key: string, error: string): void {
426 const current = this.health.get(key);
427 const failures = (current?.consecutiveFailures ?? 0) + 1;
428 const backoffIndex = Math.min(failures - 1, SSH_BACKOFF_SCHEDULE_SECONDS.length - 1);
429 const backoffSecs = withSshBackoffJitter(SSH_BACKOFF_SCHEDULE_SECONDS[backoffIndex]);
430
431 this.clearReadyControlPaths(key);
432 this.health.set(key, {
433 status: "unhealthy",
434 lastFailure: new Date(),
435 lastError: error,
436 backoffUntil: new Date(Date.now() + backoffSecs * 1000),
437 consecutiveFailures: failures,
438 });
439
440 log.warn(
441 `SSH connection failed (${failures} consecutive). Backoff for ${backoffSecs.toFixed(1)}s. Error: ${error}`
442 );
443 }
444
445 /**
446 * Clear all health state. Used in tests to reset between test cases

Callers 4

acquireConnectionMethod · 0.95
reportFailureMethod · 0.95
scheduleKillMethod · 0.95
probeConnectionMethod · 0.95

Calls 4

withSshBackoffJitterFunction · 0.90
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected