puppeteer-sharp
puppeteer-sharp copied to clipboard
Unable to launch browser after Chrome 119.0.6045.106 update
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()"
It seems that 119 is working if I update it https://github.com/hardkoded/puppeteer-sharp/pull/2354 🤔
Can you check the inner exception?
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
It seems it doesn't like the UserDataDir
Its seems to work if I delete the UserDataDir param, but that's not a solution.
Did you try using a full path? The error is coming from the browser itself.