lumberjack icon indicating copy to clipboard operation
lumberjack copied to clipboard

Protocol error (Target.getBrowserContexts): Target closed.

Open ikirker opened this issue 4 years ago • 3 comments

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/[email protected]
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)

ikirker avatar Feb 14 '20 17:02 ikirker

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

JakePartusch avatar Feb 15 '20 21:02 JakePartusch

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

arjunattam avatar Jul 23 '20 18:07 arjunattam

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

weborchard-neil avatar Jul 29 '20 08:07 weborchard-neil