diff --git a/.github/README.md b/.github/README.md index 65809392..c01c122c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -159,6 +159,20 @@ const results = await run({ ## Guides +### Usage with `@cypress/grep` + +The package is compatible with [`@cypress/grep`](https://www.npmjs.com/package/@cypress/grep). Make sure to run `require("@cypress/grep/src/plugin")(config);` before `await currents(on, config);`, for example: + +```js +setupNodeEvents(on, config) { + require("cypress-terminal-report/src/installLogsPrinter")(on); + require("@cypress/grep/src/plugin")(config); + return currents(on, config); +} +``` + +Please refer to the [issue](https://github.com/currents-dev/cypress-cloud/issues/50#issuecomment-1645095284) for details. + ### Setup with existing plugins `cypress-cloud/plugin` needs access to certain environment variables that are injected into the `config` parameter of `setupNodeEvents(on, config)`. diff --git a/CHANGELOG.md b/CHANGELOG.md index 087c3119..74b4ed1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ +## [1.9.3](https://github.com/currents-dev/cypress-cloud/compare/v1.9.2...v1.9.3) (2023-07-27) + + +### Bug Fixes + +* retry on ETIMEDOUT, add network req timeout ([#172](https://github.com/currents-dev/cypress-cloud/issues/172)) ([030ae70](https://github.com/currents-dev/cypress-cloud/commit/030ae7086eeb75397c729a79c8eefb9aa2e61d7a)) + +## [1.9.2](https://github.com/currents-dev/cypress-cloud/compare/v1.9.1...v1.9.2) (2023-07-21) + + +### Bug Fixes + +* exit with status 1 when no spec files found ([#169](https://github.com/currents-dev/cypress-cloud/issues/169)) ([9c7bfd2](https://github.com/currents-dev/cypress-cloud/commit/9c7bfd2a9bc7201af5ee9178c5b7c92cf224955e)), closes [#165](https://github.com/currents-dev/cypress-cloud/issues/165) + ## [1.9.1](https://github.com/currents-dev/cypress-cloud/compare/v1.9.0...v1.9.1) (2023-07-06) diff --git a/package-lock.json b/package-lock.json index 2ae299e3..f4c6d2b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14406,7 +14406,7 @@ } }, "packages/cypress-cloud": { - "version": "1.9.1", + "version": "1.9.3", "license": "GPL-3.0-or-later", "dependencies": { "@cypress/commit-info": "^2.2.0", diff --git a/packages/cypress-cloud/bin/cli.ts b/packages/cypress-cloud/bin/cli.ts index 35d4a614..3c2f86c7 100755 --- a/packages/cypress-cloud/bin/cli.ts +++ b/packages/cypress-cloud/bin/cli.ts @@ -13,7 +13,7 @@ async function main() { main() .then((result) => { if (!result) { - process.exit(0); + process.exit(1); } if (result.status === "failed") { process.exit(1); diff --git a/packages/cypress-cloud/lib/httpClient/config.ts b/packages/cypress-cloud/lib/httpClient/config.ts index f7c03b35..79b2f9ba 100644 --- a/packages/cypress-cloud/lib/httpClient/config.ts +++ b/packages/cypress-cloud/lib/httpClient/config.ts @@ -1,12 +1,20 @@ import { AxiosError, isAxiosError } from "axios"; export const isRetriableError = (err: AxiosError): boolean => { - if (!isAxiosError(err)) { - return false; + if (err.code === "ECONNABORTED") { + return true; } if (err.code === "ECONNREFUSED") { return true; } + if (err.code === "ETIMEDOUT") { + return true; + } + + if (!isAxiosError(err)) { + return false; + } + return !!( err?.response?.status && 500 <= err.response.status && @@ -14,7 +22,7 @@ export const isRetriableError = (err: AxiosError): boolean => { ); }; -export const getDelay = (i: number) => [15 * 1000, 30 * 1000, 60 * 1000][i - 1]; +export const getDelay = (i: number) => [5 * 1000, 10 * 1000, 30 * 1000][i - 1]; let baseURL = "https://cy.currents.dev"; export const getAPIBaseUrl = () => baseURL ?? "https://cy.currents.dev"; diff --git a/packages/cypress-cloud/lib/httpClient/httpClient.ts b/packages/cypress-cloud/lib/httpClient/httpClient.ts index fb8a8cf9..7e737559 100644 --- a/packages/cypress-cloud/lib/httpClient/httpClient.ts +++ b/packages/cypress-cloud/lib/httpClient/httpClient.ts @@ -18,7 +18,7 @@ import { maybePrintErrors } from "./printErrors"; const debug = Debug("currents:api"); const MAX_RETRIES = 3; - +const TIMEOUT_MS = 30 * 1000; let _client: AxiosInstance | null = null; export async function getClient() { @@ -28,6 +28,7 @@ export async function getClient() { const currentsConfig = await getCurrentsConfig(); _client = axios.create({ baseURL: getAPIBaseUrl(), + timeout: TIMEOUT_MS, }); _client.interceptors.request.use((config) => { @@ -68,6 +69,7 @@ export async function getClient() { ..._.pick(req, "method", "url", "headers"), data: Buffer.isBuffer(req.data) ? "buffer" : req.data, }); + return req; }); @@ -77,6 +79,7 @@ export async function getClient() { retryDelay: getDelay, // @ts-ignore onRetry, + shouldResetTimeout: true, }); return _client; } @@ -99,10 +102,11 @@ export const setCurrentsVersion = (v: string) => { function onRetry( retryCount: number, err: AxiosError<{ message: string; errors?: string[] }>, - _config: AxiosRequestConfig + config: AxiosRequestConfig ) { warn( - "Network request failed: '%s'. Next attempt is in %s (%d/%d).", + "Network request '%s' failed: '%s'. Next attempt is in %s (%d/%d).", + `${config.method} ${config.url}`, err.message, prettyMilliseconds(getDelay(retryCount)), retryCount, diff --git a/packages/cypress-cloud/package.json b/packages/cypress-cloud/package.json index 8dba124d..5634af14 100644 --- a/packages/cypress-cloud/package.json +++ b/packages/cypress-cloud/package.json @@ -1,6 +1,6 @@ { "name": "cypress-cloud", - "version": "1.9.1", + "version": "1.9.3", "main": "./dist/index.js", "author": "Currents Software Inc", "homepage": "https://github.com/currents-dev/cypress-cloud",