Cypress doesn't pass --disable-dev-shm-usage: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/chrome.coffee#L21
But Puppeteer does: https://github.com/GoogleChrome/puppeteer/blob/master/lib/Launcher.js#L37
However, in this commit that adds --disable-dev-shm-usage, it seems to cause failures to start Chrome: 7247dcfa78ad3e1d0ad032474e724a083007edda
It may be because Cypress does not run Chrome headlessly: #832
Cypress passes --disable-dev-shm-usage so that machines with small /dev/shms can run Cypress.
Original issue: #3633
A user can modify Chrome flags by adding this in their pluginsfile:
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chrome') {
console.log('Adding --disable-dev-shm-usage...')
launchOptions.args.push('--disable-dev-shm-usage')
}
return launchOptions
})
}
A user can modify Chrome flags by adding this in their pluginsfile:
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
if (browser.family === 'chromium') {
console.log('Adding --disable-dev-shm-usage...')
args.push('--disable-dev-shm-usage')
}
return args
})
}
Edited by @jennifer-shehane to note browser.family to equal chromium
Did anyone else notice that this command is not working for the new chrome (80)? I upgraded my chrome and the chrome crashes, just like in earlier versions, before this code.
Updated the workaround in the OP for Cypress 4.0.0+.
@Jacek-fstack so Chrome 80 successfully launches with --disable-dev-shm-usage, but eventually crashes? Is there an error?
I was getting this error constantly during normal usage. Usually from doing things like alt-tabbing. I was using the electron version, not chrome, to launch Cypress.
FATAL:memory.cc(22)] Out of memory. size=262144
However, I was running Cypress itself inside of a Docker container. I ended up solving this by mounting the shm directory --volume=/dev/shm:/dev/shm so that the docker container had access to all the shm the host machine has available.
On macOS there is no /dev/shm to map in, but you can use --shm-size=1gb to accomplish the same task in a cross platform manner. You can adjust the size a bit, especially considering the default is a measly 64mb.
Note that in the workaround from @flotwig above, the browser.family should be compared to 'chromium' not 'chrome'.
@adamalton Thanks! I've updated the original comment to reflect this.
The code for this is done in cypress-io/cypress#9242, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 6.0.0.
This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.0.0, please open a new issue.
Most helpful comment
I was getting this error constantly during normal usage. Usually from doing things like alt-tabbing. I was using the electron version, not chrome, to launch Cypress.
FATAL:memory.cc(22)] Out of memory. size=262144However, I was running Cypress itself inside of a Docker container. I ended up solving this by mounting the shm directory
--volume=/dev/shm:/dev/shmso that the docker container had access to all the shm the host machine has available.