Skip to content

Commit

Permalink
add chromium flag to prevent crashes in Docker on large websites
Browse files Browse the repository at this point in the history
  • Loading branch information
pocketjoso committed Apr 29, 2018
1 parent 94548d7 commit 4b0728b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const launchBrowserIfNeeded = async function ({ getBrowser }) {
args: [
'--disable-setuid-sandbox',
'--no-sandbox',
'--ignore-certificate-errors'
'--ignore-certificate-errors',
// better for Docker:
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#tips
'--disable-dev-shm-usage'
]
})
.then(browser => {
Expand Down Expand Up @@ -153,18 +156,19 @@ const generateCriticalCssWrapped = async function generateCriticalCssWrapped (
renderWaitTime: options.renderWaitTime || DEFAULT_RENDER_WAIT_TIMEOUT,
timeout: timeoutWait,
pageLoadSkipTimeout: options.pageLoadSkipTimeout,
blockJSRequests: typeof options.blockJSRequests !== 'undefined'
? options.blockJSRequests
: DEFAULT_BLOCK_JS_REQUESTS,
blockJSRequests:
typeof options.blockJSRequests !== 'undefined'
? options.blockJSRequests
: DEFAULT_BLOCK_JS_REQUESTS,
customPageHeaders: options.customPageHeaders,
screenshots: options.screenshots,
keepLargerMediaQueries: options.keepLargerMediaQueries,
// postformatting
propertiesToRemove,
maxEmbeddedBase64Length: typeof options.maxEmbeddedBase64Length ===
'number'
? options.maxEmbeddedBase64Length
: DEFAULT_MAX_EMBEDDED_BASE64_LENGTH,
maxEmbeddedBase64Length:
typeof options.maxEmbeddedBase64Length === 'number'
? options.maxEmbeddedBase64Length
: DEFAULT_MAX_EMBEDDED_BASE64_LENGTH,
debuglog,
unstableKeepBrowserAlive: options.unstableKeepBrowserAlive
})
Expand All @@ -178,7 +182,7 @@ const generateCriticalCssWrapped = async function generateCriticalCssWrapped (
'remove browser page for generateCriticalCss after ERROR, now: ' +
_browserPagesOpen
)
if (!forceTryRestartBrowser && !await browserIsRunning()) {
if (!forceTryRestartBrowser && !(await browserIsRunning())) {
debuglog(
'Chromium unexpecedly not opened - crashed? ' +
'\n_browserPagesOpen: ' +
Expand Down

0 comments on commit 4b0728b

Please sign in to comment.