diff --git a/dist/index.js b/dist/index.js index 90731c318..7dba5672a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -80421,92 +80421,6 @@ function wrappy (fn, cb) { } -/***/ }), - -/***/ 9922: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const got = __nccwpck_require__(3061) -const debug = __nccwpck_require__(8237)('@cypress/github-action') - -/** - * A small utility for checking when an URL responds, kind of - * a poor man's https://www.npmjs.com/package/wait-on. This version - * is implemented using https://github.com/sindresorhus/got - */ -const ping = (url, timeout) => { - if (!timeout) { - throw new Error('Expected timeout in ms') - } - - // make copy of the error codes that "got" retries on - const errorCodes = [...got.defaults.options.retry.errorCodes] - errorCodes.push('ESOCKETTIMEDOUT') - - // we expect the server to respond within a time limit - // and if it does not - retry up to total "timeout" duration - const individualPingTimeout = Math.min(timeout, 30000) - - // add to the timeout max individual ping timeout - // to avoid long-waiting ping from "rolling" over the end - // and preventing pinging the last time - timeout += individualPingTimeout - const limit = Math.ceil(timeout / individualPingTimeout) - - debug(`total ping timeout ${timeout}`) - debug(`individual ping timeout ${individualPingTimeout}ms`) - debug(`retries limit ${limit}`) - - const start = +new Date() - return got(url, { - headers: { - Accept: 'text/html, application/json, text/plain, */*' - }, - timeout: individualPingTimeout, - errorCodes, - retry: { - limit, - calculateDelay({ error, attemptCount }) { - if (error) { - debug(`got error ${JSON.stringify(error)}`) - } - const now = +new Date() - const elapsed = now - start - debug( - `${elapsed}ms ${error.method} ${error.host} ${error.code} attempt ${attemptCount}` - ) - if (elapsed > timeout) { - console.error( - '%s timed out on retry %d of %d, elapsed %dms, limit %dms', - url, - attemptCount, - limit, - elapsed, - timeout - ) - return 0 - } - - // if the error code is ECONNREFUSED use shorter timeout - // because the server is probably starting - if (error.code === 'ECONNREFUSED') { - return 1000 - } - - // default "long" timeout - return individualPingTimeout - } - } - }).then(() => { - const now = +new Date() - const elapsed = now - start - debug(`pinging ${url} has finished ok after ${elapsed}ms`) - }) -} - -module.exports = { ping } - - /***/ }), /***/ 9491: @@ -91897,6 +91811,92 @@ module.exports.As = safeParse __webpack_unused_export__ = defaultContentType +/***/ }), + +/***/ 2851: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const got = __nccwpck_require__(3061) +const debug = __nccwpck_require__(8237)('@cypress/github-action') + +/** + * A small utility for checking when an URL responds, kind of + * a poor man's https://www.npmjs.com/package/wait-on. This version + * is implemented using https://github.com/sindresorhus/got + */ +const ping = (url, timeout) => { + if (!timeout) { + throw new Error('Expected timeout in ms') + } + + // make copy of the error codes that "got" retries on + const errorCodes = [...got.defaults.options.retry.errorCodes] + errorCodes.push('ESOCKETTIMEDOUT') + + // we expect the server to respond within a time limit + // and if it does not - retry up to total "timeout" duration + const individualPingTimeout = Math.min(timeout, 30000) + + // add to the timeout max individual ping timeout + // to avoid long-waiting ping from "rolling" over the end + // and preventing pinging the last time + timeout += individualPingTimeout + const limit = Math.ceil(timeout / individualPingTimeout) + + debug(`total ping timeout ${timeout}`) + debug(`individual ping timeout ${individualPingTimeout}ms`) + debug(`retries limit ${limit}`) + + const start = +new Date() + return got(url, { + headers: { + Accept: 'text/html, application/json, text/plain, */*' + }, + timeout: individualPingTimeout, + errorCodes, + retry: { + limit, + calculateDelay({ error, attemptCount }) { + if (error) { + debug(`got error ${JSON.stringify(error)}`) + } + const now = +new Date() + const elapsed = now - start + debug( + `${elapsed}ms ${error.method} ${error.host} ${error.code} attempt ${attemptCount}` + ) + if (elapsed > timeout) { + console.error( + '%s timed out on retry %d of %d, elapsed %dms, limit %dms', + url, + attemptCount, + limit, + elapsed, + timeout + ) + return 0 + } + + // if the error code is ECONNREFUSED use shorter timeout + // because the server is probably starting + if (error.code === 'ECONNREFUSED') { + return 1000 + } + + // default "long" timeout + return individualPingTimeout + } + } + }).then(() => { + const now = +new Date() + const elapsed = now - start + debug(`pinging ${url} has finished ok after ${elapsed}ms`) + }) +} + +module.exports = { ping } + + /***/ }), /***/ 8570: @@ -93275,7 +93275,7 @@ const quote = __nccwpck_require__(5427) const cliParser = __nccwpck_require__(8604)() const findYarnWorkspaceRoot = __nccwpck_require__(6748) const debug = __nccwpck_require__(8237)('@cypress/github-action') -const { ping } = __nccwpck_require__(9922) +const { ping } = __nccwpck_require__(2851) const { SUMMARY_ENV_VAR } = __nccwpck_require__(1327) /** diff --git a/package.json b/package.json index facb775cd..0cd3835d1 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ ], "author": "Cypress-io", "license": "MIT", + "type": "commonjs", "bugs": { "url": "https://github.com/cypress-io/github-action/issues" },