Keep bot jobs and harness calls from hanging

This commit is contained in:
2026-10-20 12:59:24 +01:00
parent 3e13052a25
commit 3b355d68bc
16 changed files with 420 additions and 29 deletions
@@ -2,12 +2,38 @@ import { AppData } from "@/src/data/app-data";
import dockerRequest from "./docker-request";
import grabAppContainer from "./grab-app-container";
/**
* Docker can still be coming up when the app container starts (a host
* reboot, especially), so a transient failure is retried before the app
* gives up on networking.
*/
const Attempts = 3;
const RetryMs = 2000;
/**
* Makes sure the network computers run on (`AppData.DockerNetworkName`)
* exists and, when the app runs in docker, that its container is on it,
* so it reaches computers by name.
*/
export default async function ensureDockerNetwork() {
let last_error: unknown;
for (let attempt = 1; attempt <= Attempts; attempt++) {
try {
return await connectNetwork();
} catch (error: unknown) {
last_error = error;
if (attempt < Attempts) {
await new Promise((resolve) => setTimeout(resolve, RetryMs));
}
}
}
throw last_error;
}
async function connectNetwork() {
const name = AppData.DockerNetworkName;
const existing = await dockerRequest({ path: `/networks/${encodeURIComponent(name)}` });