0

I am using example code from Puppeteer-sharp but faced timeout error when calling browser.NewPageAsync(). Then I turned on Devtools and saw the page is crashed in Chromium.

var browserFetcher = new BrowserFetcher(); await browserFetcher.DownloadAsync(); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, Devtools = true }); // page is crashed in Chromium and timeout after 5 mins var page = await browser.NewPageAsync(); await page.GoToAsync("http://www.google.com"); await page.DisposeAsync(); await browser.DisposeAsync(); 

*PuppeteerSharp version is 4.0.0

2
  • You should always dispose browser and page objects at the end of execution. Add the respective Dispose() calls and see if that helps. I faced such issue once as I wasn't disposing my page objects. Commented May 20, 2021 at 6:26
  • @YashGupta, yes, forgot to put to here. Thanks for remind and help. Commented May 21, 2021 at 7:11

2 Answers 2

1

Should be due to PuppeteerSharp requires to run on Linux system in Azure (which can download and install Chromium by coding). If want to test on Windows, need to pre-install Chrome/Chromium and add ExecutablePath in LaunchOptions

// DEBUG: for running on local ExecutablePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" 

Please share if you have other solutions.

Sign up to request clarification or add additional context in comments.

Comments

1

Couple of other things that you can try out during your troubleshooting:

  • Make sure to dispose all the pages & browser being opened (as I suggested in comments).
  • Try adding the --full-memory-crash-report flag (& other flags related to Crash-handling) in your arguments to get more insight as in what's going wrong with your execution. You can literally take a mini-dump of your execution to understand the issue. The entire list of Chromium flags can be found here: Chromium Command Line Flags
  • Make sure nothing is going wrong with Garbage Collection. Since it's just a sample code, you'll have to make sure yourself that you're adding in all the necessary code required for a clean/optimised execution.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.