fix(opencode): clear readiness probe timers (#1226)

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-12 11:00:31 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent 75ad1d31b5
commit 4cbee27383
2 changed files with 44 additions and 1 deletions
@@ -29,9 +29,10 @@ export const createOpenCodeNetworkRuntime = (deps) => {
const waitForReady = async (url, timeoutMs = 10000) => {
const start = Date.now();
while (Date.now() - start < timeoutMs) {
let timeout = null;
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
timeout = setTimeout(() => controller.abort(), 3000);
const response = await fetch(`${url.replace(/\/+$/, '')}/global/health`, {
method: 'GET',
headers: {
@@ -41,6 +42,7 @@ export const createOpenCodeNetworkRuntime = (deps) => {
signal: controller.signal,
});
clearTimeout(timeout);
timeout = null;
if (response.ok) {
const body = await response.json().catch(() => null);
@@ -49,6 +51,10 @@ export const createOpenCodeNetworkRuntime = (deps) => {
}
}
} catch {
} finally {
if (timeout) {
clearTimeout(timeout);
}
}
await new Promise((resolve) => setTimeout(resolve, 100));
}