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

Protocol error (Target.getBrowserContexts): Target closed. #8

Open
ikirker opened this issue Feb 14, 2020 · 3 comments
Open

Protocol error (Target.getBrowserContexts): Target closed. #8

ikirker opened this issue Feb 14, 2020 · 3 comments

Comments

@ikirker
Copy link

ikirker commented Feb 14, 2020

I'm not very experienced at JS or npm, but I thought I'd give this a try. Unfortunately, putting it together in a fresh Vagrant box seemed to give me the error below.

I'm not sure whether this represents a problem with this package, playwright, or maybe how playwright's underlying browser instances are behaving with the virtual framebuffer?

In any case it seemed like it might be useful to post it here.

Steps to reproduce:
# In a new directory, as usual for Vagrant
vagrant init ubuntu/bionic64
vagrant up
vagrant ssh
sudo su
# Getting a more up-to-date version of node
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get update
apt-get install -y nodejs build-essential xvfb libgbm-dev nodejs
# --unsafe-perm=true seems to be needed for the playwright package install?
# Otherwise you get a "permission denied" error.
npm install -g @jakepartusch/lumberjack --unsafe-perm=true

Then:

$ xvfb-run --auto-servernum lumberjack --url https://google.com
⠋ Running accessibility checks... (1 of 100 pages){ Error: Protocol error (Target.getBrowserContexts): Target closed.
    at Promise (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crConnection.js:121:63)
    at new Promise (<anonymous>)
    at CRSession.send (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crConnection.js:120:16)
    at Function.connect (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crBrowser.js:48:68)
  message: 'Protocol error (Target.getBrowserContexts): Target closed.' }

Oh, and, since it might be relevant, here's the error I get with the npm install step if I repeat the setup steps but don't use --unsafe-perm=true:

(node:8999) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/.local-chromium'
(node:8999) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8999) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
+ @jakepartusch/lumberjack@0.6.0
added 132 packages from 171 contributors in 7.941s
⠏ Fetching sitemapError: Chromium revision is not downloaded. Run "npm install"
    at Chromium.launchBrowserApp (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/server/chromium.js:70:23)
@JakePartusch
Copy link
Owner

Hey @ikirker 👋

I was having similar issues in getting the GitHub Action to work. Like you mentioned, it seemed to be related to playwright and xvfb. Here is the config that I got to work:

jobs:
  build:
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
      - name: Install required Linux packages
        run: |
          sudo apt-get update
          sudo apt-get install libgbm-dev
          sudo apt-get install xvfb
      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Accessibility Audits
        run: |
          npm install -g @jakepartusch/lumberjack
          xvfb-run --auto-servernum lumberjack --url https://google.com

Hopefully this is helpful!

As far as the permission denied error goes, you might not have the permissions setup to globally install the package. A "quick fix" for that would be to use the npx command:
npx @jakepartusch/lumberjack --url https://google.com

@arjunattam
Copy link

I would recommend using the official Playwright GH Action to set up the environment to run web browsers.

@weborchard-neil
Copy link

I am having the same issue, but I'm just trying to run "lumberjack --url https://google.com" direct at the command line, no xvfb or GH Actions involved

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

4 participants