Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Running inside Docker #15

Open
adamstarlight opened this issue Aug 24, 2021 · 0 comments
Open

Running inside Docker #15

adamstarlight opened this issue Aug 24, 2021 · 0 comments

Comments

@adamstarlight
Copy link

Docker has a specific requirements to launch browser with --no-sandbox and --disable-setuid-sandbox and I struggle to find a way of setting those options without making a fork and editing runtime/world.js.

For now I'm trying to modify global browser variable within a BeforeFeatures hook and it doesn't work.

module.exports = function () {
  this.registerHandler('BeforeFeatures', async function () {
    if (!global.browser) {
      const options = {
        args: [
          // Required for Docker version of Puppeteer
          '--headless',
          '--no-sandbox',
          '--disable-setuid-sandbox',
          // This will write shared memory files into /tmp instead of /dev/shm,
          // because Docker’s default for /dev/shm is 64MB
          '--disable-dev-shm-usage'
        ]
      }

      global.browser = await puppeteer.launch(options)
    }
  })
}

This code is located in step-definitions folder, hook is called and a browser variable contains a valid puppeteer object.
Yet the script fails with the following:

/node_modules/cucumber/lib/cucumber/runtime/event_broadcaster.js:30
            process.nextTick(function(){ throw error; }); // prevent swallow by unhandled rejection
                                         ^

Error: node_modules/puppeteer-cucumber-js/runtime/world.js:99 Failed to launch the browser process!
[48:48:0824/105830.997835:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
    at onClose (/node_modules/puppeteer-cucumber-js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at Interface.<anonymous> (/node_modules/puppeteer-cucumber-js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
    at Interface.emit (events.js:327:22)
    at Interface.close (readline.js:424:8)
    at Socket.onend (readline.js:202:10)
    at Socket.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Any ideas?)

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

No branches or pull requests

1 participant