Look into adding `--disable-dev-shm-usage` Chrome flag

See original GitHub issue

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

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Jazzepicommented, 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.

2reactions
Jacek-fstackcommented, Feb 13, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add --disable-dev-shm-usage to default launch flags #1834
Shall we add --disable-dev-shm-usage to the default launch flags so ... Looks like there are reasons to not use --disable-dev-shm-usage by ...
Read more >
protractor - '--disable-dev-shm-usage' does not resolve the ...
The solution was to pass the options as goog:chromeOptions hash instead of chromeOptions hash.
Read more >
Default Chrome arguments — default_chrome_args • chromote
A character vector of command-line arguments passed when initializing any new instance of Chrome. Single on-off arguments are passed as single values ...
Read more >
736452 - Add an option to use /tmp instead of /dev/shm
I'm supportive of splitting the Linux shared memory code from Mac. For memfd_create, just try calling it and see if the kernel returns...
Read more >
--disable-dev-shm-usage | The AI Search Engine You Control
Chrome provides a disable-dev-shm-usage flag, but running that creates a memory leak that I can't seem to figure out how to prevent.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found