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

Error: DevToolsActivePort file doesn't exist #929

Open
bsherman-better opened this issue Apr 14, 2021 · 10 comments
Open

Error: DevToolsActivePort file doesn't exist #929

bsherman-better opened this issue Apr 14, 2021 · 10 comments

Comments

@bsherman-better
Copy link

I'm attempting to build and run a docker container for end to end testing of my electron app. I'm receiving the following error:

    Failed to create session.
    unknown error: Chrome failed to start: exited abnormally.
      (unknown error: DevToolsActivePort file doesn't exist)
      (The process started from chrome location /app/node_modules/spectron/lib/launcher.js is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

      at Object.startWebDriverSession (node_modules/webdriver/build/utils.js:34:15)

Has anyone run into this and found a solution?

@nmilev-scribe
Copy link

I'm having the same issue. The app needs some time to show the screen. Might this be the issue?

@MauriceWebb
Copy link

@bsherman-better can I see how you are instantiating your spectron's Application instance? I ran into this error when passing webdriverOptions.

@sr258
Copy link

sr258 commented Jul 11, 2021

Same issue here. This happens on my MacOS dev machine. When I reboot the computer I can successfully run the tests with Spectron once after reboot. But then all following test runs (until I reboot) produce the error for every test in the suite.

I can see the app opening in the desktop environment and the GUI shows up (and even the tests are executed before my eyes). What's also happening is that a second instance of the app opens up in the dock and immediately closes again about 10 times. Jest also doesn't exist properly once all the tests have failed:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Versions:

  • Spectron 15.0,0
  • Node 16.4.1 (ARM64)
  • Electron 13.1.6

I create the app like this:

app = new Application({
            env: {
                USERDATA: path.join(__dirname, 'data'),
                PORT: PORT,
                NODE_ENV: 'CI'
            },
            path: path.join(
                __dirname,
                '..',
                'node_modules',
                '.bin',
                'electron'
            ),
            args: ['--no-sandbox', path.join(__dirname, '..')]
        });
        return app.start();

@sr258
Copy link

sr258 commented Jul 11, 2021

After some digging I found a possible cause for my issue, maybe it will also help others:

The Node process of the electron app remained open after the tests were terminated. The result was that the normal app startup was disrupted and WebDriver couldn't connect to Electron's Chrome instance.

I already had these lines to terminate Spectron after the tests were finished:

        if (app && app.isRunning()) {
            await app.stop();
        }

I added app.mainProcess.abort() and the issue doesn't happen anymore.

@zhex900
Copy link

zhex900 commented Aug 9, 2021

I still have this problem. I can run headless in the terminal not in the docker container. Can you show me your Dockerfile?

@evertonlperes
Copy link

It's been really weird the spectron behaviour on Docker containers.
Facing the same issue and I didn't find any good solution for it yet.
Here's my Dockerfile for reference:

FROM ubuntu:20.04
ARG GITHUB_CLONE_KEY
ENV GITHUB_CLONE_KEY=$GITHUB_CLONE_KEY \
    WORKDIRAPP=/opt/rd/rancher-desktop \
    BRANCH=main \
    NODE_VER=16

##
## Set up install
##
RUN apt update && apt upgrade -y && apt dist-upgrade -y && apt install software-properties-common wget curl -y \
    && apt update -y \
    && curl -fsSL https://deb.nodesource.com/setup_${NODE_VER}.x | bash - \
    && apt install --no-install-recommends --no-upgrade \
        git nodejs unzip g++ make gnupg2 debconf-utils vim -y

##
## Installing deps for xvfb server
##
RUN apt install xvfb libxtst6 libxss1 libgtk2.0-0 libnss3 libasound2 libgconf-2-4 -y

##
## Pre test image setup
##
WORKDIR $WORKDIRAPP
RUN git clone --depth=1 --branch $BRANCH https://${GITHUB_CLONE_KEY}@github.com/xpto/xpto.git $WORKDIRAPP \
    && npm install || true
WORKDIR $WORKDIRAPP

@stephanieraymos
Copy link

stephanieraymos commented Sep 20, 2022

I'm having the same issue.

       "before all" hook: startApp for "removed actual name of test":
     Client initialization failed after 10 attempts: RuntimeError Client initialization failed after 10 attempts: 
  Error: unknown error: Chrome failed to start: exited abnormally
    (unknown error: DevToolsActivePort file doesn't exist)
    (The process started from chrome location /my/project/dir/node_modules/spectron/lib/launcher.js is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    (Driver info: chromedriver=76.0.3809.88 (e67b7e2f345cbedc6a24e0074a1a528c724f5915-refs/branch-heads/3809@{#968}),platf

@evertonlperes
Copy link

I'm having the same issue.


       "before all" hook: startApp for "removed actual name of test":

     Client initialization failed after 10 attempts: RuntimeError Client initialization failed after 10 attempts: 

  Error: unknown error: Chrome failed to start: exited abnormally

    (unknown error: DevToolsActivePort file doesn't exist)

    (The process started from chrome location /my/project/dir/node_modules/spectron/lib/launcher.js is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

    (Driver info: chromedriver=76.0.3809.88 (e67b7e2f345cbedc6a24e0074a1a528c724f5915-refs/branch-heads/3809@{#968}),platf

Hi @stephanieraymos
I had to move away from electron and replaced it by playwright. So far playwright are doing a really good job and no more weird browsers errors.

@zhex900
Copy link

zhex900 commented Sep 21, 2022

Use Playwright. Don't use this anymore.

@stephanieraymos
Copy link

This is a work application and the tests are running fine for others. So getting the whole team on board to switch soon is unlikely. Hoping to find a solution of some kind for now.

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

No branches or pull requests

7 participants