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

Function waitForHttpDown

e2e/setup/boot.ts:221–235  ·  view source on GitHub ↗
(
  url: string,
  options: { readonly timeoutMs?: number } = {},
)

Source from the content-addressed store, hash-verified

219 * a real reboot. Throws if it never goes down within the deadline.
220 */
221export const waitForHttpDown = async (
222 url: string,
223 options: { readonly timeoutMs?: number } = {},
224): Promise<void> => {
225 const deadline = Date.now() + (options.timeoutMs ?? 120_000);
226 while (Date.now() < deadline) {
227 try {
228 await fetch(url, { redirect: "manual", signal: AbortSignal.timeout(2000) });
229 } catch {
230 return; // the server (or its tunnel) is gone — the reboot took
231 }
232 await new Promise((resolve) => setTimeout(resolve, 500));
233 }
234 throw new Error(`${url} never became unreachable — the reboot may not have taken`);
235};

Callers 1

cliTargetFunction · 0.90

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected