cypress-io / cypress

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

cypress run (v13.6.5 and v13.6.6) hangs on Docker (M2 Mac) using --platform=linux/amd64 #29095

Open josh-atkins opened 7 months ago

josh-atkins commented 7 months ago

Current behavior

Setup

cypress run fails with 13.6.5 and 13.6.6

When using cypress version 13.6.5 and 13.6.6, executing cypress run fails as it just hangs right after announcing it is about to start the test.

DEBUG: cypress:* prints this before hanging:

cypress:server:run about to run spec {
   "spec":{
      "absolute":"/cypress/cypress/e2e/test.cy.ts",
      "fileExtension":".ts",
      "fileName":"test",
      "name":"test.cy.ts",
      "relative":"cypress/e2e/test.cy.ts"
   },
   "isHeadless":true,
   "browser":{
      "channel":"stable",
      "displayName":"Electron",
      "family":"chromium",
      "majorVersion":118,
      "name":"electron",
      "path":"",
      "version":"118.0.5993.159"
   }
} +32ms

The entire debug output of DEBUG: cypress:*:error is:

  cypress:snapshot:error TypeError [ERR_INVALID_ARG_TYPE]: The "paths[1]" argument must be of type string. Received undefined
  cypress:snapshot:error     at new NodeError (node:internal/errors:405:5)
  cypress:snapshot:error     at validateString (node:internal/validators:162:11)
  cypress:snapshot:error     at Object.resolve (node:path:1097:7)
  cypress:snapshot:error     at Object.resolve (evalmachine.<anonymous>:1:765400)
  cypress:snapshot:error     at resolvePathsAndParent (<embedded>:4511:1077511)
  cypress:snapshot:error     at customRequire (<embedded>:4511:1076567)
  cypress:snapshot:error     at c (<embedded>:2827:111097)
  cypress:snapshot:error     at <embedded>:2827:111632
  cypress:snapshot:error     at <embedded>:4511:18500
  cypress:snapshot:error     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) +0ms
  cypress:snapshot:error TypeError [ERR_INVALID_ARG_TYPE]: The "paths[1]" argument must be of type string. Received undefined
  cypress:snapshot:error     at new NodeError (node:internal/errors:405:5)
  cypress:snapshot:error     at validateString (node:internal/validators:162:11)
  cypress:snapshot:error     at Object.resolve (node:path:1097:7)
  cypress:snapshot:error     at Object.resolve (evalmachine.<anonymous>:1:765400)
  cypress:snapshot:error     at resolvePathsAndParent (<embedded>:4511:1077539)
  cypress:snapshot:error     at customRequire (<embedded>:4511:1076567)
  cypress:snapshot:error     at c (<embedded>:2827:111097)
  cypress:snapshot:error     at <embedded>:2827:111632
  cypress:snapshot:error     at <embedded>:4511:18500
  cypress:snapshot:error     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) +1ms

And it hangs as follows:

Screenshot 2024-03-08 at 22 17 48

cypress run succeeds with 13.6.4

When using cypress version 13.6.4 with the setup otherwise identical, the test completes as expected except it instead prints this message:

[754:0308/191324.311425:ERROR:object_proxy.cc(590)] Failed to call method: org.freedesktop.portal.Settings.Read: object_path= /org/freedesktop/portal/desktop: unknown error type: 

Desired behavior

cypress run executes successfully with the latest version, without hanging, and without error messages.

Test code to reproduce

  1. Clone this repo: https://github.com/DI-Studios/cypress-in-docker-hangs-on-mac
  2. Start the container from the repo root with docker compose run --interactive --build --rm cypress
  3. Inside the container run cypress run

Cypress Version

13.6.6

Node version

v20.11.0

Operating System

macOS 14.4

Debug Logs

See gist: https://gist.github.com/josh-distudios/5640d35efc0b542df0a78706e1ad6f9e

Other

I've had a look at the cypress:snapshot:error to see if I can work out where it's coming from, but it appears on 13.6.4 which runs successfully so I'm not sure it's related to this error.

I've also searched the logs for the term "error" which showed that playwright-webkit is missing, but when I installed this locally it didn't have resolve the issue.

jennifer-shehane commented 7 months ago

I wasn't able to recreate this with the example on my Intel Mac. I'll have to get someone with an M1 to try it next.

Electron was updated in 13.6.5, so I would suspect that is the cause for this behavior.

josh-atkins commented 7 months ago

Great - thanks!

Travis-Kirton commented 6 months ago

Just adding - I'm also seeing this and can reproduce the issue from @josh-atkins github repo. I'm running an M1 Mac Sonoma 14.3.1.

This has been causing pain while dockerising our tests and I had no idea why!

mengfei0053 commented 6 months ago

Hey is there any solution, I have the same problem

mengfei0053 commented 6 months ago

I refer to this https://github.com/cypress-io/cypress-docker-images/blob/master/base/centos7/Dockerfile to build my image。 And I change nodejs to 16.x, it alwys hangs。 I also tried cypress/base, this works. I cannot use cypress/base in my company, I can only use centos to build images myself。 pc: Apply M2 Pro.

jennifer-shehane commented 6 months ago

@mengfei0053 Our minimum supported version with recent versions of Cypress is Node 18+ https://docs.cypress.io/guides/getting-started/installing-cypress#Nodejs

tangzhen commented 4 months ago

@josh-atkins Are you utilizing Colima as the Docker container? I recently encountered the same issue and upon checking your demo repository, I found some information:

So, I think the problem might occur inside the Docker container(colima). Unfortunately, I don't have a Docker Desktop license, so I can't verify whether this problem also occurs on Docker Desktop.

mwtrew commented 4 months ago

Same issue here on M1 with MacOS 14.5, Cypress 13.6.4 works under Docker (this image) with --platform=linux/amd64 (using Rosetta 2) but later Cypress versions hang indefinitely.

dbclkh commented 4 months ago

This is a M(1 2 3) issue on macbooks... :/

My cypress tests works fine on a Lenovo and on our build server - but not on my Macook Pro M3 😦

gabrilogos1985 commented 3 months ago

Same issue on Mac OS 13.6 , processor M1

e2e-test      | [SUCCESS]  Verified Cypress!       /root/.cache/Cypress/13.13.0/Cypress
e2e-test      | 
e2e-test      | DevTools listening on ws://127.0.0.1:58611/devtools/browser/ff0bfa3a-3e9d-4a26-9ad6-aee0b7212352
e2e-test      | Couldn't find tsconfig.json. tsconfig-paths will be skipped

it hangs.

nedkoh commented 2 months ago

I wasn't able to recreate this with the example on my Intel Mac. I'll have to get someone with an M1 to try it next.

Electron was updated in 13.6.5, so I would suspect that is the cause for this behavior.

@jennifer-shehane any updates on this? From my conversation with our Cypress TAM I understand that access to M1 and M2 architecture at Cypress is limited but we are severely impaired by this as our local environment doesn't match the tests in CI and produces inconsistent results.