Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress tests fail in air-gapped network on Firefox #1298

Closed
ChadiEM opened this issue Feb 10, 2025 · 3 comments
Closed

Cypress tests fail in air-gapped network on Firefox #1298

ChadiEM opened this issue Feb 10, 2025 · 3 comments
Assignees

Comments

@ChadiEM
Copy link

ChadiEM commented Feb 10, 2025

Current behavior

In an air gapped network, running a component or e2e tests using cypress on Firefox using the cypress/included docker image fails with the following error:

Cypress failed to make a connection to Firefox.

This usually indicates there was a problem opening the Firefox browser.

FetchError: request to https://raw.githubusercontent.com/mozilla/geckodriver/release/Cargo.toml failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (file:///root/.cache/Cypress/14.0.2/Cypress/resources/app/packages/server/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:518:28)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5)
    at TLSSocket.emit (node:events:518:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

This is likely a regression introduced in release 13.15.1 which started using geckodriver.

Desired behavior

I expect the test to run in an air gapped network. It should not send any request to the internet.

Test code to reproduce

Any test in Firefox in an air-gapped network.

Cypress Docker Image

cypress/included:14.0.2

Other

I also attempted to override the environment variables supported by geckodriver to use a local path

GECKODRIVER_VERSION = '0.35.0'
GECKODRIVER_CDNURL = 'file:///path/to/geckodriver/'

But it failed node-fetch does not support file:.

Related issue

cypress-io/cypress#31036

@MikeMcC399
Copy link
Collaborator

@ChadiEM

Thanks for opening a new issue specifically for Docker! Here are the results of my analysis with a recommendation for you:

Situation

Firefox testing with Cypress fails in an air-gapped network environment.

Background

The npm package geckodriver by default dynamically downloads and caches an architecture-dependent geckodriver from GitHub. This default behavior requires an Internet connection, meaning that these images cannot be used in an air-gapped environment.

Assessment

None of the published Cypress Docker images, nor ones generated using cypress/factory, contain a cached geckodriver required for Firefox testing.

To cover this situation in a general way would require making geckodriver into a parameter for cypress/factory. This could be looked at as a feature request.

The environment variable GECKODRIVER_AUTO_INSTALL documented in Installing allows an auto-install of the driver.

Recommendation

In order to reach a workable solution quickly, I suggest using a customized Docker image similar to cypress/included that includes a cached version of the geckodriver.

Example Docker image

First in an environment with Internet connectivity:

git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images
cd examples/basic-mini

Create a Dockerfile.geckodriver with the following contents:

ARG FIREFOX_VERSION='135.0'
ARG CYPRESS_VERSION='14.0.2'

FROM cypress/factory

COPY . /opt/app
WORKDIR /opt/app
ENTRYPOINT ["cypress", "run"]
RUN GECKODRIVER_AUTO_INSTALL=1 npm install geckodriver --no-package-lock
RUN npm uninstall geckodriver

Then execute:

docker build -f Dockerfile.geckodriver -t test-firefox-included .

Disconnect network and execute:

docker run -it --rm -v .:/app -w /app --entrypoint cypress test-firefox-included run -b firefox

@MikeMcC399
Copy link
Collaborator

@ChadiEM

Please give feedback if this suggestion is helpful to you.

@MikeMcC399
Copy link
Collaborator

@ChadiEM

A workaround has been provided as an incident resolution. It does not however resolve the underlying problem that Cypress and Cypress Docker images testing Firefox require an Internet connection at some point in their setup stage.

If you want to suggest any changes to regular Cypress Docker images or the factory build process for instance, please open a new issue as there would be additional topics that would need consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants