question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chromium stopped working in Alpine Docker Gitlab

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.11.0
  • Platform / OS version: Alpine Linux v3.8 within Docker (node:alpine) GitLab CI
  • URLs (if applicable): -
  • Node.js version: 11.6.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. npm install puppeteer
  2. npm test

What is the expected result?

the tests are running within headless chromium

What happens instead?

The following error occurs:

(95/95) Installing chromium@edge (71.0.3578.98-r2)
[...]

(node:104) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
(node:104) 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:104) [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.

[...]

    Chromium revision is not downloaded. Run "npm install" or "yarn install"

      at Launcher.launch (node_modules/puppeteer/lib/Launcher.js:115:15)

Notes

After puppeteer refused to work with the bundled chromium (ENOENT error), as suggested in https://github.com/GoogleChrome/puppeteer/issues/379#issuecomment-437688436, thread linked from the main official troubleshooting documentation, I’ve decided to use the system-installed chromium with the following configuration snippet:

// gitlab-ci:yaml
image: node:alpine

variables:
  IS_CI: "true"

[...]

test:
    stage: test
    script:
        - echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && apk add --no-cache chromium@edge nss@edge harfbuzz@edge
        - npm test
    dependencies:
        - prepare
    artifacts:
        paths:
        - coverage
    only:
        - branches
        - tags
    variables:
        CHROME_BIN: '/usr/bin/chromium-browser'
// package.json
{
  "devDependencies": {
    "jest": "^23.6.0",
    "jest-puppeteer": "3.7.0",
    "puppeteer": "^1.11.0"
  }
}
// jest-puppeteer.config.js
const defaultConfig = {
  launch: {
    args: ['--no-sandbox']
  }
};

if (process.env.IS_CI) {
  defaultConfig.launch.executablePath = '/usr/bin/chromium-browser';
  defaultConfig.launch.args = ['--disable-dev-shm-usage'];
}

module.exports = defaultConfig;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
brandonroscommented, Mar 16, 2019
"Error: Failed to launch chrome!
ewFailed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[0316/234355.845954:FATAL:zygote_host_impl_linux.cc(187)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid). 
Received signal 6
  r8: 0000000000000078  r9: 00007f480e59114c r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd620a26d0 r13: 00000000000000a0 r14: 00007ffd620a26f0 r15: 00007ffd620a2c40
  di: 0000000000000002  si: 00007ffd620a25a0  bp: 00007ffd620a25a0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f480e547fa0  sp: 00007ffd620a2588
  ip: 00007f480e547fa0 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/app/node_modules/puppeteer/lib/Launcher.js:342:14)
    at Interface.helper.addEventListener (/app/node_modules/puppeteer/lib/Launcher.js:331:50)
    at Interface.emit (events.js:194:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
# Avoid sandbox for Puppeteer
RUN mkdir -p /home/nobody/Downloads \
  && chown -R nobody:nobody /home/nobody \
  && chown -R nobody:nobody /app

# Switch user
USER nobody

These are the relevant parts of my Dockerfile. Not quite sure how to get around this error?

1reaction
walirtcommented, Sep 10, 2020
"Error: Failed to launch chrome!
ewFailed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[0316/234355.845954:FATAL:zygote_host_impl_linux.cc(187)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid). 
Received signal 6
  r8: 0000000000000078  r9: 00007f480e59114c r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd620a26d0 r13: 00000000000000a0 r14: 00007ffd620a26f0 r15: 00007ffd620a2c40
  di: 0000000000000002  si: 00007ffd620a25a0  bp: 00007ffd620a25a0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f480e547fa0  sp: 00007ffd620a2588
  ip: 00007f480e547fa0 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/app/node_modules/puppeteer/lib/Launcher.js:342:14)
    at Interface.helper.addEventListener (/app/node_modules/puppeteer/lib/Launcher.js:331:50)
    at Interface.emit (events.js:194:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
# Avoid sandbox for Puppeteer
RUN mkdir -p /home/nobody/Downloads \
  && chown -R nobody:nobody /home/nobody \
  && chown -R nobody:nobody /app

# Switch user
USER nobody

These are the relevant parts of my Dockerfile. Not quite sure how to get around this error?

I add --cap-add=SYS_ADMIN in docker run can solve this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chromium stopped working in Alpine Docker Gitlab #3740
I think the latest addendum to the troubleshooting regarding Alpine helped me getting puppeteer working (I mean, it does run puppeteer, the fact ......
Read more >
alpine (docker@latest) chromium fails to start. (#8197) · Issues
I cannot run chromium latest (61) on alpine 3.6 (using docker:latest). I suspect there is some bug / missing depdency.
Read more >
Docker (node:8.15-alpine) + Chromium + Karma unit tests not ...
I'm trying to run my frontend tests on Docker (node:8.15-alpine) using Chromium and Karma, however I'm getting lots of ChromeHeadless related ...
Read more >
Troubleshooting - Puppeteer
Make sure all the necessary dependencies are installed. You can run ldd chrome | grep not on a Linux machine to check which...
Read more >
Puppeteer in alpine docker with chromium headless dosent ...
But sadly nothing worked. Can I have a fix or better way for doing it? Chromium version - 93.0.4577.82, Firefox version - 94.0,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found