I am using puppeteer-sharp to render some pages as PDFs. I'd like to know if the page has any issues rendering at runtime in the browser, so I set up some event handlers:
_page.Error += (sender, args) =>
{
_logger.LogCritical(args.Error);
};
_page.PageError += (sender, args) =>
{
_logger.LogError(args.Message);
};
_page.Console += (sender, args) =>
{
switch (args.Message.Type)
{
case ConsoleType.Error:
_logger.LogError(args.Message.Text);
break;
case ConsoleType.Warning:
_logger.LogWarning(args.Message.Text);
break;
default:
_logger.LogInformation(args.Message.Text);
break;
}
};
When I get an error on the page, args.Message.Text
seems to just contain "ERROR JSHandle@error"
. This isn't very helpful.
I tested normal console.log
on the page and that logs fine, it seems to be an issue with Errors.
Is there something I need to do to get something readable out of these errors?
Update: I tried accessing args.Message.Args
and using JsonValueAsync()
on those args, but that seems to cause some async weirdness that breaks the devtools protocol because I started getting timeout errors and then errors complaining about web sockets being broken.
It appears this is an issue with puppeteer itself: https://github.com/GoogleChrome/puppeteer/issues/3397