1
0
mirror of synced 2026-01-04 09:06:46 -05:00
Files
docs/.github/actions-scripts/lib/wait-until-url-is-healthy.js
Evan Bonsignori 7e198d5348 don't wait forever
2022-08-18 11:16:59 -07:00

23 lines
546 B
JavaScript

import got from 'got'
// Will try for 20 minutes, (15 * 80) seconds / 60 [seconds]
const RETRIES = 80
const DELAY_SECONDS = 15
/*
* Promise resolves once url is healthy or fails if timeout has passed
* @param {string} url - health url, e.g. docs.com/healthz
*/
export async function waitUntilUrlIsHealthy(url) {
try {
await got.head(url, {
retry: {
limit: RETRIES,
calculateDelay: ({ computedValue }) => Math.min(computedValue, DELAY_SECONDS * 1000),
},
})
return true
} catch {}
return false
}