cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.06k stars 3.19k forks source link

SSL error code 1, net_error -100 - The tests intermittently fail with SIGSEGV event #24778

Closed ps37 closed 1 year ago

ps37 commented 1 year ago

Current behavior

We recently upgraded our cypress from 8.7.0 to 10.11.0 and started seeing the following error in our Jenkins build pipelines. Some of the tests are intermittently failing in the very beginning in the Mocha before hook with:

Running:  operator/operator-organizations.feature.cy.ts                                   (7 of 8)
[105736:1121/143716.572886:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned -1, SSL error code 1, net_error -100
[105736:1121/143716.573223:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned -1, SSL error code 1, net_error -100
[105736:1121/143716.573400:ERROR:ssl_client_socket_impl.cc(983)] handshake failed; returned -1, SSL error code 1, net_error -100
The Test Runner unexpectedly exited via an exit event with signal SIGSEGV

However, this was not the case previously on the 8.7.0 version.

Desired behavior

The tests should not fail intermittently and continue the execution like how they were in version 8.7.0

Test code to reproduce

Before each test, we navigate to a URL(cy.navigateTo("/operator")) as shown below:

describe("Should show organizations", () => {
    let organizationsPageWo: OrganizationsPageWidgetObject<Cypress.Chainable>;

    before(() => {
      cy.intercept(new RegExp("https://.*/orgStats?.*")).as("fetchOrgs");
      cy.navigateTo("/operator");
      cy.wait("@fetchOrgs", { timeout: 60000 });
    });

    beforeEach(() => {
      organizationsPageWo = find(OrganizationsPageWidgetObject) as OrganizationsPageWidgetObject<Cypress.Chainable>;
    });

    it("Should visit organizations page", () => {
      organizationsPageWo
        .getHeader({ options: { timeout: 3000 } })
        .unwrap()
        .should("exist");
    });
})

And inside the custom navigateTo command, we programmatically do SSO login as shown below:

/**
 * Authenticate with the org using the refresh token in an environment variable.
 */
export function getAuthToken(): Chainable {
  const accessTokenReqOptions = {
    method: "POST",
    url: isDevOrStagingEnv() ? AUTHORIZATION_URL : AUTHORIZATION_URL_PROD,
    qs: {
      refresh_token: isDevOrStagingEnv()
        ? `${ORG_REFRESH_TOKEN}`
        : `${ORG_REFRESH_TOKEN_PROD}`,
    },
    headers: AUTH_HEADERS,
  };
  return cy.request(accessTokenReqOptions);
}

/**
 * Visits the location after authenticating.
 */
export function navigateTo(location: string): Chainable {
  return getAuthToken().then((accessTokenRes) => {
    cy.visit(location, {
      onBeforeLoad: (contentWindow) => {
        contentWindow.sessionStorage.setItem(Cypress.env("authToken"), JSON.stringify(accessTokenRes.body));
      },
    });
  });
}

Cypress Version

10.11.0

Node version

14.21.0

Operating System

"os":"Linux", "arch":"x64"

Debug Logs

log.txt

Other

No response

BlueWinds commented 1 year ago

I'm not sure this is the issue you're running into - it might be unrelated - but aliases are reset before each test.

Note: all aliases are reset before each test. A common user mistake is to create aliases using the before hook. Such aliases work in the first test only!

You might be well served with cy.session(), which is designed to help out with exactly the workflow you've implemented.

Again not sure either of these directly address the bug report, but they'd be things to try out at least.

chrisbreiding commented 1 year ago

Going to close due to inactivity. Please post a comment if this is still an issue and we can re-open it.

arbrsts commented 6 months ago

We are encountering the same issue when running cypress in our CI pipeline


  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        3                                                                                │
  │ Passing:      3                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     navigation/tab/HorizontalTab.cy.tsx                                              │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
[2013:0510/082333.936818:ERROR:ssl_client_socket_impl.cc(978)] handshake failed; returned -1, SSL error code 1, net_error -101
[2013:0510/082333.952534:ERROR:ssl_client_socket_impl.cc(978)] handshake failed; returned -1, SSL error code 1, net_error -101

Below are the podman commands used to create the runner environment from docker:io/node:18 base image

  podman run -d -i --rm -v ./:/app:Z --name ${RUNNER_ID}_node --pod ${RUNNER_ID} docker.io/node:18 sh
  podman exec -w /app ${RUNNER_ID}_node sh -c "apt update && apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb"
  podman exec -w /app ${RUNNER_ID}_node npm ci
  podman exec -w /app ${RUNNER_ID}_node npm run test
grazieleoliveira commented 4 months ago

Same problem here