Piotr Krzemiński
12/10/2021, 10:49 AM[2021-12-10T10:37:29.209Z] > Task :frontend-react:browserTest
[2021-12-10T10:37:29.209Z] Cannot start ChromeHeadless
[2021-12-10T10:37:29.209Z] [1210/103728.346077:ERROR:<http://zygote_host_impl_linux.cc|zygote_host_impl_linux.cc>(90)] Running as root without --no-sandbox is not supported. See <https://crbug.com/638180>.
[2021-12-10T10:37:29.209Z] ChromeHeadless stdout:
[2021-12-10T10:37:29.209Z] ChromeHeadless stderr: [1210/103728.346077:ERROR:<http://zygote_host_impl_linux.cc|zygote_host_impl_linux.cc>(90)] Running as root without --no-sandbox is not supported. See <https://crbug.com/638180>.
I told Gradle plugin to look into `karma.config.d`:
testTask {
useKarma {
useConfigDirectory("karma.config.d")
}
}
and there I have
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadlessNoSandbox'],
// you can define custom flags
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
})
}
but I'm not even sure if this config is picked up. Too bad Kotlin/JS's Gradle plugin does't allow building on top of available configs. E.g. if I could define:
fun useChromeHeadlessNoSandbox() {
config.customLaunchers["ChromeHeadlessNoSandbox"] = CustomLauncher("ChromeHeadless").apply {
flags.add("--no-sandbox")
}
useChromeLike("ChromeHeadlessNoSandbox")
}
it could work fine and without defining any extra files. Unfortunately, config
is private nowPiotr Krzemiński
12/10/2021, 10:53 AM> No browsers configured for task ':frontend-react:browserTest'
but it's not true - I did define them in karma.config.d/karma.jsPiotr Krzemiński
12/10/2021, 11:00 AMdelay(10000)
in my unit test, then kept polling with ps aux | grep chrome
to see Chrome's arguments. I didn't see --no-sandbox
Piotr Krzemiński
12/10/2021, 11:25 AMtestTask {
useKarma {
useConfigDirectory("$projectDir/karma.config.d")
useChromeHeadless()
}
}
karma.config.d/karma.conf.js
config.set({
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
// Needed to work on Jenkins. Otherwise, there's an error:
// 'Running as root without --no-sandbox is not supported. See <https://crbug.com/638180.>'
flags: ['--no-sandbox'],
}
}
});
I'm not sure what was the issue, too many moving parts and too little time to pinpoint the issue 🤷Piotr Krzemiński
12/10/2021, 11:25 AMuseChromeHeadlessNoSandbox()
? it seems pretty popular now in k8s daysPiotr Krzemiński
12/10/2021, 11:32 AMPiotr Krzemiński
12/10/2021, 12:17 PMPiotr Krzemiński
12/10/2021, 3:49 PMIlya Goncharov [JB]
12/13/2021, 8:37 AM