puppeteer: Protocol error (Target.createTarget): Target closed.
Steps to reproduce
Tell us about your environment:
- Puppeteer version: 0.11.0 (we have it on our roadmap to upgrade to 1.0.0)
- Platform / OS version: Ubuntu 16
- Node.js version: 6.11.3
What steps will reproduce the problem? Very random and rare. Out of over 2500 requests, we have 20 of these failures.
Please include code that reproduces the issue.
const args = ['--no-sandbox', '--disable-setuid-sandbox'];
return puppeteer.launch({ args }).then(browser =>
browser
.newPage()
.then(page => page.setContent(html).then(() => page))
.then(page => page.pdf(pdfParams).then(() => page))
.then(page => page.setViewport(viewport).then(() => page))
.then(page => page.screenshot(screenshotParams))
.then(() => browser.close())
.catch(e => {
if (browser) {
browser.close();
}
return Promise.reject(e);
})
.then(() => { stuff });
);
html is just a bunch of ejs rendered html.
What is the expected result? No protocol error
What happens instead?
Randomly returns Protocol error (Target.createTarget): Target closed.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 60
Commits related to this issue
- try await browser.close() on exit before nz.cleanup() to remove puppeteer protocol failures (did not seem to affect functionality), see: https://github.com/GoogleChrome/puppeteer/issues/1947 — committed to talmobi/twitch-webchat by talmobi 5 years ago
- test(e2e-flakiness): simplify browser.close calls in test fixtures (#3540) #### Description of changes This was originally motivated by wanting to audit all the `browser.close` instances to see if... — committed to microsoft/accessibility-insights-web by dbjorge 4 years ago
I’ve also encountered this error.
Not sure if this helps anyone, but I had the issue while running it with aws lambdas. For me it solved the issue that I made sure I closed the chrome properly via
await browser.close();
before finishing the lambda. I think otherwise the browser doesn’t cleanup properly and the next session might stumble over some leftovers.This would definitely happen if you were calling
page.close
without awaiting it, and then later callingbrowser.close()
.It is unlikely that these problems are related. It would be very helpful if someone could send a script I can run that reproduces this problem.
I am still facing this, even with browser.close.
Can you post the stack trace along with the error? The only usage of
Target.createTarget
in Puppeteer is inbrowser.newPage()
. This error would happen if you call browser.close() whilebrowser.newPage()
has yet to resolve.I had a similar issue. Sorted by using the following to launch.
From my experiments it seems this is caused by the same glibc bug as #2207 (https://sourceware.org/bugzilla/show_bug.cgi?id=19329). Launching chrome a lot of times triggers a race condition in glibc which crashes chrome. When pipe mode is used the crashing chrome triggers the error in this ticket. When websockets are used the error in #2207 is triggered.
I’m having this exact issue on an Apple Silicon machine running a docker image.
When deployed to Google Cloud, it works fine. It seems to only be on Apple Silicon. Any ideas?
I’m seeing the same issue as @Joebayld on an M1 macbook. Works fine anywhere else.
This may happens if you use
--single-process
arg.Has anyone been able to get
browser.newPage()
to work on M1 Mac within Docker?I’m also seeing this error:
I was having this same problem running puppeteer inside a docker container under my Macbook M1 and actually adding this arg make the puppeteer works fine
Also experiencing this error on M1 Macbook. Is this issue stale?
I am getting the same error. Any solution with M1 Macs
docker buildx build --push --platform linux/amd64,aarch64 --tag your.docker.image.repo/your-image:tag .
This solved our problem with development on PC and M1 mac.
I was able to fix this issue on my tests by calling
await page.close();
in all tests so that beforeafterAll(()=>browser.close());
runs, all of the pages should be closed. Thanks to @JoelEinbinder for the fix.We’ve got the same issue on M1 Macbook, full error is:
For anyone else having this problem, this occurred for me consistently whenever I was trying to
await page.goto()
within aforeach()
ormap()
loop. When I switched to using afor()
loop instead it worked fine. I haven’t debugged it to understand why but it’s the only difference that worked for me. Hope this helps someonei got the same. I read some people had more luck going to v16, so i did but now i get other errors:
Sep 10 14:53:50Z sr-bot app/web.1 [Nest] 20 - 09/10/2023, 2:53:49 PM ERROR [ExceptionHandler] Failed to launch the browser process! Sep 10 14:53:50Z sr-bot app/web.1 [0910/145349.802510:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
Frustrating that it works locally but not on heroku 😦
Hello,
for me I had to close the extensions before the browser like this.
The image I built is based on alpine. What I’ve done was just rebuild the image on an arm64 platform. Since the image I built is the base image that needs to support multiple platforms, I have added and pushed the manifest. You can use
buildx
to simply it, but the performance to me was too slow. I ended with having it built on AWS code pipeline with 2 code build projects build two platforms in parallel, and another code build project that creates the manifest and push to registry.Hope this is helpful.
@marcelpanse i opened #7916, I’m having the same problem.
Same problem on M1 mac
same problem here on M1 mac