INNER CODE UNIT · TypeScript

probe

rajnandan1/kener · scripts/main.ts:26

  const probe = async (check: () => Promise<unknown>): Promise<boolean> => {
    let timer: ReturnType<typeof setTimeout> | undefined;
    try {
      const result = await Promise.race([
        check(),
        new Promise((_, reject) => {
          timer = setTimeout(() => reject(new Error("health probe timeout")), 2000);
        }),
      ]);
      return result !== false;
    } catch {
      return false;
    } finally {
      clearTimeout(timer);
    }
  };

  // Reports component health. Always 200 so healthcheck-driven restarters do

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…