PuppeteerSharp stucks at await Puppeteer.LaunchAsync(...)

116 Views Asked by At

I've just migrated my WinForms Application to .Net 8. PuppeteerSharp version 14.0.0 I'm working on Windows 11 Version 22H2 and Visual Studio 2022 (Version 17.8.3 x64) After migration, the execution stucks on line of shown below (Puppeteer.LaunchAsync):

public async static Task<IBrowser> GetBrowserAsync()
{
    IBrowser browser = null;

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

        // Create an instance of the browser and configure launch options                        
        browser = await Puppeteer.LaunchAsync(new LaunchOptions // <== Stucks here
        {
            Headless = false,
            IgnoreHTTPSErrors = true,
            Args = new[]
            {
                "--no-sandbox",
                "--disable-setuid-sandbox",
                "--disable-web-security",
                "--disable-features=IsolateOrigins,site-per-process",
                "--start-maximized"
            },
        });
        
        return browser;
    }
    catch (Exception)
    {
        throw;
    }
}

I leave running for long time and didn't throw any exception. I can't understand what happening. Has anyone experienced this problem?

I have been tried modify my code to do same thing but in a different way, but always stucks on same place. I simplified the code the maximum I could and same issue. I updated the PuppeteerSharp to latest version (14.0.0) and stucks on same place Modified Windows Forms Target OS to latest and stucks on same place Modified Windows Forms Platform Target to: AnyCPF, x64 and x86 and stucks on same place

1

There are 1 best solutions below

0
Giovanni On

I've just find the issue.

Just changed: var response = _service.ProcessScraping(robotId, companies.ToArray()).Result;

to:

var response = await _service.ProcessScraping(robotId, companies.ToArray());

And everything worked as expected.