cypress: Specs finish but cypress never exits - hangs stopping Xvfb

Current behavior

I am trying to get my tests running in AWS CodeBuild and the tests are all running but then it just hangs at the end, when it tries to stop xvfb, due to X99 lock file not being found. It works as expected when I run it on my local Windows machine though.

This is what runs after the table of test results (AWS CodeBuild - Debian 9.13 - Chrome headless): Note: Other users also report it happening with an image FROM cypress/browsers:node16.14.0-chrome99-ff97

Logs with DEBUG=cypress:xvfb,xvfb

2022-05-27T04:55:20.925Z cypress:cli child event fired { event: 'exit', code: 1, signal: null }
2022-05-27T04:55:20.925Z cypress:cli Stopping Xvfb
2022-05-27T04:55:20.925Z xvfb restoring process.env.DISPLAY variable
2022-05-27T04:55:20.926Z xvfb lock filename /tmp/.X99-lock
2022-05-27T04:55:20.926Z xvfb lock file /tmp/.X99-lock
2022-05-27T04:55:20.936Z xvfb lock file /tmp/.X99-lock not found when stopping

Then it hangs.

It never gets to this point: cypress:cli child event fired { event: 'close', code: 2, signal: null }

Desired behavior

Exit when the tests are finished.

Test code to reproduce

It’s running like this:

set -e -o pipefail
cypress run --browser chrome 2>&1 | tee "cypress/logs/log.txt"
exit $?

Note: I have also tried using electron and the same thing happens.

Cypress Version

9.7.0 Also tested 9.5.1, 9.4.1, 9.3.1, 9.2.1, 8.7.0, 8.6.0, 8.5.0 - It is happening with all those.

Other

Here is the log output with DEBUG=cypress:xvfb,xvfb, minus the build and test parts where nothing of interest happened:

Build process setup...

Installing source NPM dependencies...


> my-project@1.0.0 cy:ci
> start-server-and-test start http-get://localhost:4200 cy:run-ci

1: starting server using command "npm run nonprod"
and when url "[ 'http-get://localhost:4200' ]" is responding with HTTP status code 200
WAIT_ON_INTERVAL is set to 5000
WAIT_ON_TIMEOUT is set to 900000
running tests using command "npm run cy:run-ci"

Application build process...

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Running Cypress E2E tests and logging output to file...

It looks like this is your first time using Cypress: 9.7.0

[STARTED] Task without title.
2022-05-27T07:58:00.990Z xvfb lock filename /tmp/.X99-lock
2022-05-27T07:58:00.990Z xvfb lock filename /tmp/.X99-lock
2022-05-27T07:58:00.990Z xvfb setting DISPLAY :99
2022-05-27T07:58:00.992Z xvfb all Xvfb arguments [ ':99', '-screen', '0', '1280x1024x24' ]
2022-05-27T07:58:01.000Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:01.011Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:01.021Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:01.031Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:01.042Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:01.042Z xvfb lock file /tmp/.X99-lock found after 40 ms

✔ Compiled successfully.
2022-05-27T07:58:02.898Z xvfb restoring process.env.DISPLAY variable
2022-05-27T07:58:02.898Z xvfb lock filename /tmp/.X99-lock
2022-05-27T07:58:02.898Z xvfb lock file /tmp/.X99-lock
2022-05-27T07:58:02.929Z xvfb lock file /tmp/.X99-lock not found when stopping
[SUCCESS] Task without title.

Opening Cypress...
2022-05-27T07:58:02.933Z xvfb lock filename /tmp/.X99-lock
2022-05-27T07:58:02.933Z xvfb setting DISPLAY :99
2022-05-27T07:58:02.933Z xvfb all Xvfb arguments [ ':99', '-screen', '0', '1280x1024x24' ]
2022-05-27T07:58:02.936Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:02.947Z xvfb checking if started by looking for the lock file /tmp/.X99-lock
2022-05-27T07:58:02.947Z xvfb lock file /tmp/.X99-lock found after 10 ms
Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[915:0527/075804.596661:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[915:0527/075804.605980:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.

tput: No value for $TERM and no -T specified
================================================================================

  (Run Starting)

                                                                                                    
... Tests run ...

tput: No value for $TERM and no -T specified
================================================================================

  (Run Finished)

... Tests results table ...

2022-05-27T07:59:28.421Z xvfb restoring process.env.DISPLAY variable
2022-05-27T07:59:28.422Z xvfb lock filename /tmp/.X99-lock
2022-05-27T07:59:28.422Z xvfb lock file /tmp/.X99-lock
2022-05-27T07:59:28.432Z xvfb lock file /tmp/.X99-lock not found when stopping

About this issue

Most upvoted comments

I migrated to @cypress/schematic@2.5.0 and it solved my issue with angular 14 and spec not ending.

TLDR:

ng add @cypress/schematic@2.5.0

See details: https://github.com/cypress-io/cypress/tree/develop/npm/cypress-schematic

@jtneal your issue is different to this issue. The bug this issue relates to causes the process to hand in this step cypress:cli child event fired { event: 'exit', code: 1, signal: null } +9s and this next part never runs at all: cypress:cli child event fired { event: 'close', code: 1, signal: null } +1ms Your log also doesn’t mention xvfb.

This issue is also not specifically related to Angular 14. I suggest opening a separate issue for your issue, if there is not already one, for the best chance of a resolution to both our issues.

@ceelian That error “Could not find a Cypress configuration file.” doesn’t seem like the same error this issue is about.