Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into adding --disable-dev-shm-usage Chrome flag #5336

Closed
flotwig opened this issue Oct 10, 2019 · 8 comments · Fixed by #9242
Closed

Look into adding --disable-dev-shm-usage Chrome flag #5336

flotwig opened this issue Oct 10, 2019 · 8 comments · Fixed by #9242

Comments

@flotwig
Copy link
Contributor

flotwig commented Oct 10, 2019

Current behavior:

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: 7247dcf

It may be because Cypress does not run Chrome headlessly: #832

Desired behavior:

Cypress passes --disable-dev-shm-usage so that machines with small /dev/shms can run Cypress.

Original issue: #3633

Workaround (4.0.0 and up)

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
  })
}

Workaround (pre-4.0.0)

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

@Jacek-fstack
Copy link

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.

@flotwig
Copy link
Contributor Author

flotwig commented Feb 13, 2020

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?

@Jazzepi
Copy link

Jazzepi commented Feb 26, 2020

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.

@dragon788
Copy link

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.

@adamalton
Copy link

Note that in the workaround from @flotwig above, the browser.family should be compared to 'chromium' not 'chrome'.

@jennifer-shehane
Copy link
Member

@adamalton Thanks! I've updated the original comment to reflect this.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 19, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 19, 2020

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 24, 2020

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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants