question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use Page.DisposeAsync and Browser.DisposeAsync hang forever

See original GitHub issue

Before you file a bug, have you:

  • Tried upgrading to newest version of PuppeteerSharp, to see if your issue has already been resolved and released? Yes, I am using the latest version.

  • Checked existing open and closed issues, to see if the issue has already been reported? Yes, I do search quite a lots and also try to find solution from the original puppeteer repo also.

  • Tried reproducing your problem in a new isolated project? Not yet, I might try next time but since it’s a production issue, so I need to fix it quickly.

  • Considered if this is a general question and not a bug?. For general questions please use StackOverflow. Not sure but after I change to use Dispose() seems these chrome process close correctly.

Description

I am running puppeteer-sharp with docker, I found there are quite a lot of zombie chrome process never be kill. I was try to use tini as entry point (tips from here tips) also no luck. I was check the logs, I found that some DisposeAsync sometime never complete. So I change to use Dispose instead, looks good so far.

Complete minimal example reproducing the issue

There is not complete code right now, I might update later. I just simply to call DisposeAsync. E.g.

var options = new LaunchOptions
{
    Headless = Configurations.Puppeteer.Headless,
    Args = new string[]
    {
        "--no-sandbox",
        "--disable-dev-shm-usage",
        "--incognito"
    }
};
Browser = await Puppeteer.LaunchAsync(options, loggerFactory);
var browserPages = await Browser.PagesAsync();
if (browserPages.Length > 0) {
    Page = browserPages[0];
    await Task.WhenAll(browserPages.Skip(1).Select(x => x.CloseAsync()));
} else {
    Page = await Browser.NewPageAsync();
}

// some other steps 

logger.LogInformation("browser is disposing");
await Page.DisposeAsync();
await Browser.DisposeAsync();
// this log sometime never print out
logger.LogInformation("browser is disposed");

Expected behavior:

Browser dispose correctly, and no zombie process

Actual behavior:

I found some zombie process never be kill

Versions

  • Which version of PuppeteerSharp are you using?
  • Version: 2.0.3
  • Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.0.
  • netcoreapp3.1, aspnet core mvc

Additional Information

Running puppeteer-sharp in docker, dockerfile similar with the one you provided, I just added tini as entry-point. (BTW, I think the docker example should also add this and run with args --disable-dev-shm-usage).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
pmdeverscommented, Jun 30, 2020

https://github.com/puppeteer/puppeteer/issues/1825

Have found that the following arguments resolved the zombie processes

Args = new[] { “–headless”, “–no-sandbox”, “–disable-gpu”, “–single-process”, “–no-zygote” }

also added this https://github.com/Yelp/dumb-init

0reactions
DHcllycommented, Dec 28, 2022

still exist this case in new version in puppeteer 8

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use PuppeteerSharp.Page.DisposeAsync in Puppeteer- ...
Use the DisposeAsync method in PuppeteerSharp package in your next Puppeteer-sharp project with LambdaTest Automation Testing Advisor.
Read more >
Implement a DisposeAsync method
Learn how to implement DisposeAsync and DisposeAsyncCore methods to perform asynchronous resource cleanup.
Read more >
c# - DisposeAsync method deadlocks when shutting down ...
NET Core application stops the DI framework automatically (and correctly) calls DisposeAsync() on all singleton instances that are registered.
Read more >
C# Functional Programming In-Depth (14) Asynchronous ...
The C# async programming model uses System.Threading. ... From some point on, I am preparing to build my site while browsing various sites....
Read more >
Cliff diving into async in .NET Core and C# 8
So if you write "await using," it will only call the DisposeAsync. Only if you then remove the await from the using, it...
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