wallabyjs / atom-wallaby

Wallaby.js atom package starter
Other
57 stars 6 forks source link

Failure using headless chrome on Linux #59

Closed paulequilibrio closed 6 years ago

paulequilibrio commented 6 years ago

Hi, I'm trying to use headless chrome in my tests but the wallaby console just show:

Test run failure: Sandbox load failed, status: failed: Chrome is not running

The relevant part of my wallaby.js is:

env: {
  kind: 'chrome',
  runner: 'google-chrome-stable'
}

My Chrome is version 61.0.3163.79 (Official Build) (64-bit) on Linux. Doesn't matter if chrome is running or not, I always receive that message.

ArtemGovorov commented 6 years ago

Try removing the runner: 'google-chrome-stable' bit.

ArtemGovorov commented 6 years ago

Also please

paulequilibrio commented 6 years ago

Looking into chrome-launcher's source code I was able to figure out the failure reason.

The chrome-launcher module adds a --disable-setuid-sandbox flag when running on linux platform.

There is some way to wallaby override this behaviour?

ArtemGovorov commented 6 years ago

Looks like Chrome launcher is adding the --disable-setuid-sandbox flag in addition to the flags passed from outside, so there must be a reason why Chrome team is doing it and are making this flag not optional. I'd recommend raising an issue/question in the launcher repo about it.

Having said that, there is way in wallaby to override this behaviour if you like. In your wallaby config, you may intercept process spawn calls made by chrome launcher and just remove the flag:

const cp = require('child_process');
const spawn = cp.spawn;
cp.spawn = function () {
  const flags = arguments[1];
  if (flags.length) {
    arguments[1] = flags.filter(f => f !== '--disable-setuid-sandbox');
  }
  return spawn.apply(this, arguments);
};

// the rest of your wallaby config
module.exports = function (wallaby) {
  ...
};
paulequilibrio commented 6 years ago

Thanks for your quick responses! Your workaround works fine for me here.

ArtemGovorov commented 6 years ago

Awesome, thanks for the update!