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

JavaScript heap out of memory #1006

Closed
maximegheraille opened this issue Dec 22, 2023 · 9 comments
Closed

JavaScript heap out of memory #1006

maximegheraille opened this issue Dec 22, 2023 · 9 comments
Assignees
Labels

Comments

@maximegheraille
Copy link

maximegheraille commented Dec 22, 2023

Hi,

I have a very strange behavior with the cypress/factory:latest image (cypress 13.6.0)

ARG CHROME_VERSION='120.0.6099.109-1'

FROM cypress/factory:latest

WORKDIR .

RUN npm install -g pnpm

COPY package.json pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile

RUN pnpm exec playwright install --with-deps webkit

COPY . .

I keep getting this error when it run the first test.

image

It works fine when using WORKDIR /opt/app and COPY . /opt/app,
I am not sure if I am doing something wrong or if this is a real issue.

@MikeMcC399
Copy link
Collaborator

@maximegheraille

Are you still suffering with this error when you use the current latest cypress/factory:4.0.2?

@maximegheraille
Copy link
Author

maximegheraille commented Jun 8, 2024

Hi @MikeMcC399

I just tried with the latest cypress/factory:latest and it still fails,
The run is available here

@MikeMcC399
Copy link
Collaborator

@maximegheraille

Thank you for providing an example repo https://github.com/maximegheraille/cypress-crash !

This does not look like it is a Cypress Docker image issue.

  • "Maximum call stack size exceeded" in your logs is more indicative of an application / test error.
  • The test spec e2e/cypress/integration/sf/components/tests.ts results in a failure "An uncaught error was detected outside of a test" when run outside of Docker.

Run with Docker (your logs)

The logs show "RangeError" / "Maximum call stack size exceeded". This normally indicates an error in the test. There are many reports of this in the issue list on https://github.com/cypress-io/cypress/issues.

https://github.com/maximegheraille/cypress-crash/actions/runs/9427747238/job/25972247930#step:4:1602 shows:

  cypress:lifecycle:child:run_require_async_child:435 uncaught exception: {
  name: 'RangeError',
  message: 'Maximum call stack size exceeded',
  stack: 'RangeError: Maximum call stack size exceeded\n' +
    '    at /root/.cache/Cypress/13.6.2/Cypress/resources/app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:86:10\n' +

Run without Docker

The test spec e2e/cypress/integration/sf/components/tests.ts results in a failure "An uncaught error was detected outside of a test" when run outside of Docker.

Attempting to run the test on Ubuntu 22.04.4 LTS under Node.js 20.10.0

npm install pnpm@latest -g
git clone https://github.com/maximegheraille/cypress-crash
cd cypress-crash/e2e
pnpm install --frozen-lockfile
pnpm exec playwright install --with-deps webkit
pnpm cypress run --config-file custom.config.ts -b chrome
  Running:  tests.ts                                                                        (1 of 1)


  1) An uncaught error was detected outside of a test

  0 passing (4s)
  1 failing

  1) An uncaught error was detected outside of a test:
     CypressError: The following error originated from your test code, not from Cypress.

  > Cannot call `cy.get()` outside a running test.

This usually happens when you accidentally write commands outside an `it(...)` test.

If that is the case, just move these commands inside an `it(...)` test.

Check your test file for errors.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

https://on.cypress.io/cannot-execute-commands-outside-test
      at ensureRunnable (https://www.google.com/__cypress/runner/cypress_runner.js:137809:58)
      at cy.<computed> [as get] (https://www.google.com/__cypress/runner/cypress_runner.js:138384:7)
      at Object.create (https://www.google.com/__cypress/runner/cypress_runner.js:161345:19)
      at Object.only (https://www.google.com/__cypress/runner/cypress_runner.js:161301:21)
      at context.describe.only (https://www.google.com/__cypress/runner/cypress_runner.js:161091:27)
      at createRunnable (https://www.google.com/__cypress/runner/cypress_runner.js:145401:31)
      at Function.only (https://www.google.com/__cypress/runner/cypress_runner.js:145462:14)
      at Object.create (https://www.google.com/__cypress/runner/cypress_runner.js:161345:19)
      at context.describe.context.context (https://www.google.com/__cypress/runner/cypress_runner.js:161064:27)
      at createRunnable (https://www.google.com/__cypress/runner/cypress_runner.js:145401:31)
      at <unknown> (https://www.google.com/__cypress/runner/cypress_runner.js:145462:14)
      at <unknown> (https://www.google.com/__cypress/runner/cypress_runner.js:110821:23)
      at tryCatcher (https://www.google.com/__cypress/runner/cypress_runner.js:1807:23)
      at Object.gotValue (https://www.google.com/__cypress/runner/cypress_runner.js:6476:18)
      at Object.gotAccum (https://www.google.com/__cypress/runner/cypress_runner.js:6465:25)
      at Object.tryCatcher (https://www.google.com/__cypress/runner/cypress_runner.js:1807:23)
      at Promise._settlePromiseFromHandler (https://www.google.com/__cypress/runner/cypress_runner.js:1519:31)
      at Promise._settlePromise (https://www.google.com/__cypress/runner/cypress_runner.js:1576:18)
      at Promise._settlePromise0 (https://www.google.com/__cypress/runner/cypress_runner.js:1621:10)
      at Promise._settlePromises (https://www.google.com/__cypress/runner/cypress_runner.js:1701:18)
      at _drainQueueStep (https://www.google.com/__cypress/runner/cypress_runner.js:2407:12)
      at _drainQueue (https://www.google.com/__cypress/runner/cypress_runner.js:2400:9)

@MikeMcC399 MikeMcC399 self-assigned this Jun 9, 2024
@maximegheraille
Copy link
Author

Hi @MikeMcC399

I verified the test itself, it seems there was an error which I fixed and simplified the setup a bit.
Even with these changes it still fails on the docker run

@MikeMcC399
Copy link
Collaborator

@maximegheraille

Please try copying your app to /opt/app instead of /.
I forked your repo and ran it successfully with this Dockerfile

ARG CHROME_VERSION='120.0.6099.109-1'
ARG NODE_VERSION='20.10.0'

FROM cypress/factory:latest

WORKDIR /opt/app
# Set NODE_OPTIONS environment variable
ENV NODE_OPTIONS="--max_old_space_size=8192"
RUN npm install -g pnpm

COPY package.json pnpm-lock.yaml /opt/app

RUN pnpm install --frozen-lockfile

RUN pnpm exec playwright install --with-deps webkit

COPY . /opt/app

@MikeMcC399
Copy link
Collaborator

I also ran your app successfully using a standard Cypress Docker image in a GitHub Actions workflow.

You can see the workflow in the fork. This doesn't use cypress/factory and is therefore simpler.

@maximegheraille
Copy link
Author

for now I do copy everything to /opt/app but it should also work ifyou copy everything to the root of the docker container.

@MikeMcC399
Copy link
Collaborator

I did not investigate further but I suspect that if the app is in the root directory, then Cypress may get overloaded searching for the Cypress spec(s) to run, since it has to search through all the files in the operating system.

/opt/app is what the documentation shows so I would recommend to follow it as default "best practice"

@MikeMcC399
Copy link
Collaborator

I'm going to close this issue now.

According to the conventions described in the Filesystem Hierarchy Standard it should not be expected for an application to be placed directly in the / directory.

The problem is resolved by following the documentation
https://github.com/cypress-io/cypress-docker-images/tree/master/factory#in-the-dockerfile
and using /opt/app as the working directory.

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

No branches or pull requests

2 participants