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

Error event not raised when page crashes #2494

Closed
Madajevas opened this issue Mar 12, 2024 · 4 comments
Closed

Error event not raised when page crashes #2494

Madajevas opened this issue Mar 12, 2024 · 4 comments

Comments

@Madajevas
Copy link

Description

  • I am starting browser like var browser = Puppeteer.LaunchAsync(new LaunchOptions { Headless = true);
  • Creating a page var page = browser.NewPageAsync()
  • Hooking on error event: page.Error += (e, a) => System.Diagnostics.Debugger.Break();
  • Navigating to page that has memory leak and in crashed the page. JS to crash:
    <script type="text/javascript">
        var a = [...Array(2 ** 32 - 1)];
    </script>
    

Page does crash, however error (PageError too) event is never raised. Am I missing something?

Versions

Observed on .NET8 and PuppeteerSharp 14.1.0 (have not tried any older version).

@kblok
Copy link
Member

kblok commented Mar 12, 2024

hmmm @Madajevas I'm getting the error.
image

using System;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using PuppeteerSharp;

namespace PuppeteerSharpPdfDemo
{
    class MainClass
    {
        public static async Task Main(string[] args)
        {
            var options = new LaunchOptions { Headless = false };

            Console.WriteLine("Downloading chromium");

            using var browserFetcher = new BrowserFetcher();
            await browserFetcher.DownloadAsync();

            Console.WriteLine("Navigating google");
            await using var browser = await Puppeteer.LaunchAsync(options);
            await using var page = await browser.NewPageAsync();

            page.Error += (sender, e) =>
            {
                Console.WriteLine("Error raised: " + e.Error);
            };

            await page.GoToAsync("file:///Users/dario/Code/puppeteer/puppeteer/test/src/crash.html");


            if (!args.Any(arg => arg == "auto-exit"))
            {
                Console.ReadLine();
            }
        }
    }
}

@Madajevas
Copy link
Author

Even your sample does not raise the event... Full html file I use:

<html>
 <head>
  <title>Crash it</title>
 </head>
 <body>
  <script type="text/javascript">
    var a = [...Array(2 ** 32 - 1)];
  </script>
 </body>
</html>

@kblok
Copy link
Member

kblok commented Mar 12, 2024

I used pretty much the same HTML

<html>
<head>
    <title>Crash</title>
</head>
<body>
  <script type="text/javascript">
    var a = [...Array(2 ** 32 - 1)];
</script>
    <h1>Crash</h1>
    <p>Crash</p>
</body>
</html>

@Madajevas
Copy link
Author

It must be something with my local chrome installation. Tried executing the same inside docker container and it worked as expected.

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

No branches or pull requests

2 participants