Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/word-wrap-1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis authored Aug 25, 2023
2 parents a1a7ecd + 6e31596 commit 76270f6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cypress-cloud/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions packages/cypress-cloud/lib/httpClient/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
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 &&
err.response.status < 600
);
};

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";
Expand Down
10 changes: 7 additions & 3 deletions packages/cypress-cloud/lib/httpClient/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) => {
Expand Down Expand Up @@ -68,6 +69,7 @@ export async function getClient() {
..._.pick(req, "method", "url", "headers"),
data: Buffer.isBuffer(req.data) ? "buffer" : req.data,
});

return req;
});

Expand All @@ -77,6 +79,7 @@ export async function getClient() {
retryDelay: getDelay,
// @ts-ignore
onRetry,
shouldResetTimeout: true,
});
return _client;
}
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress-cloud/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 76270f6

Please sign in to comment.