Allow Heroku 500 error codes while polling (#21795)
* Extract allowable Heroku error checks into a reusable function * Add 500 to the list of allowable Heroku errors while polling
This commit is contained in:
@@ -8,9 +8,10 @@ const SLEEP_INTERVAL = 5000
|
|||||||
const HEROKU_LOG_LINES_TO_SHOW = 25
|
const HEROKU_LOG_LINES_TO_SHOW = 25
|
||||||
const DELAY_FOR_PREBOOT_SWAP = 135000 // 2:15
|
const DELAY_FOR_PREBOOT_SWAP = 135000 // 2:15
|
||||||
|
|
||||||
// Allow for a few 404 (Not Found) or 429 (Too Many Requests) responses from the
|
// Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from
|
||||||
// semi-unreliable Heroku API when we're polling for status updates
|
// the semi-unreliable Heroku API when we're polling for status updates
|
||||||
const ALLOWED_MISSING_RESPONSE_COUNT = 5
|
const ALLOWED_MISSING_RESPONSE_COUNT = 5
|
||||||
|
const ALLOWABLE_ERROR_CODES = [404, 429, 500]
|
||||||
|
|
||||||
export default async function deployToProduction({
|
export default async function deployToProduction({
|
||||||
octokit,
|
octokit,
|
||||||
@@ -179,7 +180,7 @@ export default async function deployToProduction({
|
|||||||
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
|
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
buildAcceptableErrorCount += 1
|
buildAcceptableErrorCount += 1
|
||||||
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -232,7 +233,7 @@ export default async function deployToProduction({
|
|||||||
release = result
|
release = result
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
releaseAcceptableErrorCount += 1
|
releaseAcceptableErrorCount += 1
|
||||||
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -291,7 +292,7 @@ export default async function deployToProduction({
|
|||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
dynoAcceptableErrorCount += 1
|
dynoAcceptableErrorCount += 1
|
||||||
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -440,6 +441,10 @@ async function getTarballUrl({ octokit, owner, repo, sha }) {
|
|||||||
return tarballUrl
|
return tarballUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAllowableHerokuError(error) {
|
||||||
|
return error && ALLOWABLE_ERROR_CODES.includes(error.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
function announceIfHerokuIsDown(error) {
|
function announceIfHerokuIsDown(error) {
|
||||||
if (error && error.statusCode === 503) {
|
if (error && error.statusCode === 503) {
|
||||||
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
|
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import createStagingAppName from './create-staging-app-name.js'
|
|||||||
const SLEEP_INTERVAL = 5000
|
const SLEEP_INTERVAL = 5000
|
||||||
const HEROKU_LOG_LINES_TO_SHOW = 25
|
const HEROKU_LOG_LINES_TO_SHOW = 25
|
||||||
|
|
||||||
// Allow for a few 404 (Not Found) or 429 (Too Many Requests) responses from the
|
// Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from
|
||||||
// semi-unreliable Heroku API when we're polling for status updates
|
// the semi-unreliable Heroku API when we're polling for status updates
|
||||||
const ALLOWED_MISSING_RESPONSE_COUNT = 5
|
const ALLOWED_MISSING_RESPONSE_COUNT = 5
|
||||||
|
const ALLOWABLE_ERROR_CODES = [404, 429, 500]
|
||||||
|
|
||||||
export default async function deployToStaging({
|
export default async function deployToStaging({
|
||||||
octokit,
|
octokit,
|
||||||
@@ -238,7 +239,7 @@ export default async function deployToStaging({
|
|||||||
build = appSetup.build
|
build = appSetup.build
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
setupAcceptableErrorCount += 1
|
setupAcceptableErrorCount += 1
|
||||||
if (setupAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (setupAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -321,7 +322,7 @@ See Heroku logs for more information:\n${logUrl}`
|
|||||||
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
|
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
buildAcceptableErrorCount += 1
|
buildAcceptableErrorCount += 1
|
||||||
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -374,7 +375,7 @@ See Heroku logs for more information:\n${logUrl}`
|
|||||||
release = result
|
release = result
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
releaseAcceptableErrorCount += 1
|
releaseAcceptableErrorCount += 1
|
||||||
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -480,7 +481,7 @@ See Heroku logs for more information:\n${logUrl}`
|
|||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Allow for a few bad responses from the Heroku API
|
// Allow for a few bad responses from the Heroku API
|
||||||
if (error.statusCode === 404 || error.statusCode === 429) {
|
if (isAllowableHerokuError(error)) {
|
||||||
dynoAcceptableErrorCount += 1
|
dynoAcceptableErrorCount += 1
|
||||||
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
|
||||||
continue
|
continue
|
||||||
@@ -646,6 +647,10 @@ async function getTarballUrl({ octokit, owner, repo, sha }) {
|
|||||||
return tarballUrl
|
return tarballUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAllowableHerokuError(error) {
|
||||||
|
return error && ALLOWABLE_ERROR_CODES.includes(error.statusCode)
|
||||||
|
}
|
||||||
|
|
||||||
function announceIfHerokuIsDown(error) {
|
function announceIfHerokuIsDown(error) {
|
||||||
if (error && error.statusCode === 503) {
|
if (error && error.statusCode === 503) {
|
||||||
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
|
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
|
||||||
|
|||||||
Reference in New Issue
Block a user