puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

Unable to launch browser after Chrome 119.0.6045.106 update

Open abennouna12 opened this issue 2 years ago • 6 comments

Hello,

I have a .NET 7 project using Puppeteer 12.0.0 in a Windows environment.

Here is how I launch my browser:

var launchOptions = new LaunchOptions
{
    ExecutablePath = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
    UserDataDir = "./data",
    Headless = true,
    Args = new[]
    {
        "--disable-gpu",
        "--disable-dev-shm-usage",
        "--disable-setuid-sandbox",
        "--no-sandbox",
        "--disk-cache-size=0",
        "--media-cache-size=0",
        "--no-zygote"
    }
};

var browser = await Puppeteer.LaunchAsync(launchOptions);

Everything was fine before chrome was upgraded. I didn't change my configuration.

Any help to solve this issue is appreciated.

Thanks.

Here is the stacktrace

{"Failed to launch browser! "}

"   at PuppeteerSharp.States.ProcessStartingState.<StartCoreAsync>d__6.MoveNext()\r\n   at PuppeteerSharp.States.ProcessStartingState.<StartCoreAsync>d__6.MoveNext()\r\n   at PuppeteerSharp.Launcher.<LaunchAsync>d__8.MoveNext()\r\n   at PuppeteerSharp.Launcher.<LaunchAsync>d__8.MoveNext()"

abennouna12 avatar Nov 03 '23 16:11 abennouna12

It seems that 119 is working if I update it https://github.com/hardkoded/puppeteer-sharp/pull/2354 🤔

kblok avatar Nov 03 '23 21:11 kblok

Can you check the inner exception?

kblok avatar Nov 03 '23 21:11 kblok

Hello,

I shared the inner exception earlier.

Here is the initial exception

"   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n   at Weda.Infrastructure.Standard.Configurations.PDFGenerator.Startup.RegisterPuppeteer(IServiceCollection services, String headlessBrowserExecutablePath) in D:\\Workspaces\\Workspace3\\Infrastructure\\Weda.Infrastructure.Standard\\Configurations\\PDFGenerator\\Startup.cs:line 31\r\n   at Wedoc.Config.DependencyInjection.RegisterWedoc(IServiceCollection services, AppConfig appConfig) in D:\\Workspaces\\Workspace3\\Wedoc\\Wedoc\\Config\\DependencyInjection.cs:line 42\r\n   at Program.<Main>$(String[] args) in D:\\Workspaces\\Workspace3\\Wedoc\\Wedoc\\Program.cs:line 35"

Earlier I gave you a sample code with the parameters of my call

In fact, here is my code:

  public static void RegisterPuppeteer(this IServiceCollection services, string headlessBrowserExecutablePath)
        {
            var launchOptions = new LaunchOptions
            {
                ExecutablePath = headlessBrowserExecutablePath,
                UserDataDir = "./data",
                Headless = true,
                Args = new[]
                {
                    "--disable-gpu",
                    "--disable-dev-shm-usage",
                    "--disable-setuid-sandbox",
                    "--no-sandbox",
                    "--disk-cache-size=0",
                    "--media-cache-size=0",
                    "--no-zygote"
                }
            };

            services.AddSingleton<IPdfGenerator, PuppeteerPdfGenerator>();
            services.AddSingleton<IBrowserOptions>(launchOptions);
            services.AddSingleton(Puppeteer.LaunchAsync(launchOptions).Result);
        }

I launch the browser using DI.

Sometimes, I also have this exception (that never appeared with earlier versions of chrome)

"One or more errors occurred. (Failed to launch browser! [1104/223207.337:ERROR:command_line_handler.cc(137)] Could not create directory ./data: AccÞs refusÚ. (0x5)\r\n)"

Thanks for your help

abennouna12 avatar Nov 04 '23 21:11 abennouna12

It seems it doesn't like the UserDataDir

kblok avatar Nov 04 '23 21:11 kblok

Its seems to work if I delete the UserDataDir param, but that's not a solution.

abennouna12 avatar Nov 04 '23 21:11 abennouna12

Did you try using a full path? The error is coming from the browser itself.

kblok avatar Nov 06 '23 17:11 kblok