Skip to content
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

System.NullReferenceException from PuppeteerSharp.Frame.WaitForSelectorAsync #2375

Open
pirinit opened this issue Dec 12, 2023 · 3 comments
Open

Comments

@pirinit
Copy link

pirinit commented Dec 12, 2023

We are using PuppeteerSharp v13.0.1(.NET 6 web app ) for connecting to a remote chromium browser (it runs in a docker container in Azure, browserless/chrome:latest) navigating to multiple URLs in our own system(we are using Angular for our FE) and generating PDF documents.
During the export process we are using single IBrowser instance with 10 IPage (tabs). Randomly we get WaitTaskTimeoutException, TargetClosedException and NavigationException, which are properly handled and retry logic is run.

Yesterday I've seen for the first time
"System.NullReferenceException: Object reference not set to an instance of an object.
at PuppeteerSharp.Frame.WaitForSelectorAsync(String selector, WaitForSelectorOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Frame.cs:line 121"

I've checked the source code here:
https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/Frame.cs

but there isn't anything specific.
The issue happens both in my local dev environment and in Azure Web App.

This code is run
await page.GoToAsync($"{rpBaseUrl}/form/{stageId}/display/{user.Id}?pdfPrintHeadless=true"); await page.WaitForSelectorAsync("body.form-loaded"); var pdf = await page.PdfDataAsync(new PdfOptions { MarginOptions = new PuppeteerSharp.Media.MarginOptions { Bottom = "0.3in", Left = "0.3in", Right = "0.3in", Top = "0.3in" }, Landscape = false, PrintBackground = true });

To me it looks like a bug in the library, but maybe I'm missing something... Any ideas or suggestions are welcome...

@kblok
Copy link
Member

kblok commented Dec 12, 2023

Hey @pirinit. Do you have a more complete stack trace?

@pirinit
Copy link
Author

pirinit commented Dec 13, 2023

hi @kblok :)
thanks for the quick reply.
the other part of the stack trace is our own code, which I think is not relevant

but still, here it is:
12/12/2023 7:59:40 AM: System.NullReferenceException: Object reference not set to an instance of an object. 12/12/2023 7:59:40 AM: at PuppeteerSharp.Frame.WaitForSelectorAsync(String selector, WaitForSelectorOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Frame.cs:line 121 at Core.Services.PdfGeneration.PdfFormExportService.DownloadFormPdf(IPage page, String competitionId, Guid stageId, String stageNameForDisplay, UserWithAdminReviewStatusViewModel user) in C:\agent\_work\822\s\src\Core\Services\PdfGeneration\PdfFormExportService.cs:line 625 at Core.Services.PdfGeneration.PdfFormExportService.GeneratePdfsForFormStage(String competitionId, Guid stageFormId, String adminReviewIdForDisplay) in C:\agent\_work\822\s\src\Core\Services\PdfGeneration\PdfFormExportService.cs:line 585 at Core.Services.PdfGeneration.PdfFormExportService.StartPdfGeneration(IEnumerable1 stageIds, String adminReviewIdForDisplay) in C:\agent_work\822\s\src\Core\Services\PdfGeneration\PdfFormExportService.cs:line 505 `

@kblok
Copy link
Member

kblok commented Dec 13, 2023

As you see. It's hard to get more data from that line 121. If you want to move forward, I think you could either clone this repo and link the project instead of using the nuget package or give me access to some URL I can use to debug it (you can send private info by email)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants