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
puppeteer.launch() never returns when using --no-startup-window #4298
Comments
I add here my use case to explain why I can't use the workaround of #3630 I'm using puppeteer to render pdf document from web page. It is a web service and I wanted to allow each instance of my service to have multiple "renderer" (multiple pages in facts). To implement this, I'm using a generic pool implementation which allow me to create a pool of page ready to be used. const puppeteer = require('puppeteer')
const genericPool = require('generic-pool')
const { goToLogin } = require('./utils')
let pagePool
// Browser singleton
const getBrowser = (() => {
let memoizedBrowserPromise
return () => {
if (!memoizedBrowserPromise) {
memoizedBrowserPromise = puppeteer.launch({ args: ['--no-startup-window'] })
}
return memoizedBrowserPromise
}
})()
// The generic pool uses a factory with 3 functions:
// - create: create a new ressource.
// - destroy: destroy the given ressource. Commonly used to destroy a ressource on error
// - validate: validate is a ressource is still valid. Used by the pool to periodically check if it needs to clean up some ressources.
const pageFactory = {
async create() {
const browser = await getBrowser()
// Here, I can't use `const [page] = await browser.pages()` since this function can be called at any time.
const page = await browser.newPage()
const onError = (error) => pagePool.destroy(page)
page.on('error', onError)
page.on('pageerror', onError)
await goToLogin(page)
return page
},
async destroy(page) {
if (page.isClosed()) await page.close()
},
async validate(page) {
return page.isClosed()
},
}
pagePool = genericPool.createPool(pageFactory, { min: 1, max: 5 })
module.exports = pagePool |
|
I didn't even notice that it wasn't working on headless... It's difficult to see what's happening in headless ^^ Thanks for the advice, if it has no real impact, I will ignore this then. |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
Please include code that reproduces the issue.
What is the expected result?
The
launch
function should return a promise which resolve to a browser.What happens instead?
The
launch
call is hanging and never resolve.An other closed issue already reported this problem (#3630), but I can't use the given workaround in my case. And i think that even if there is a workaround, this is still bug since the behavior is unexpected.
The text was updated successfully, but these errors were encountered: