puppeteer-sharp
puppeteer-sharp copied to clipboard
What might cause the 'Failed to launch browser!' error?
In my application, this error occurs approximately 20% of the time, while it functions normally 80% of the time. After the issue appears, manually opening and then closing the browser resolves the problem—though it still occasionally reoccurs.
Failed to launch browser!
在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 在 PuppeteerSharp.States.ProcessStartingState.<StartCoreAsync>d__6.MoveNext() 位置 /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:行号 83 --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 PuppeteerSharp.States.ProcessStartingState.<StartCoreAsync>d__6.MoveNext() 位置 /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:行号 89 --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 在 PuppeteerSharp.Launcher.<LaunchAsync>d__8.MoveNext() 位置 /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:行号 71 --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 PuppeteerSharp.Launcher.<LaunchAsync>d__8.MoveNext() 位置 /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:行号 104
For me it is happening also. When i restart my system then it again start working.
Same exceptions keep being thrown on my Windows PC as well. I am using the latest version of Puppeteer Sharp (20.1.3). Since in my case the code logic is supposed to be scheduled regularly without the need to manually relaunch the system or the browser each time, it will be highly appreciated if this bug can be addressed. Many thanks!
I used Puppeteer.ConnectAsync instead of Puppeteer.Launch, and then it could run normally. Before that, you need to use the '--remote-debugging-port=9222' command to run the browser process, which will start your browser in remote debugging mode.
The InnerException could give us more clues about what's going on.
PuppeteerSharp version 20.1.0.
I hope to be in right place where write this.
I have a similar problem on a Windows Server 2019 with an application on .NET 8.0 . Seems, when the server goes on a low memory condition, this problem comes out.
This is the stack trace:
PuppeteerSharp.ProcessException: Failed to launch browser! [15748:14212:0423/140610.848:ERROR:ukm_database_backend.cc(148)] Failed to open UKM database: -8 sql::Database is not opened.
at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 83
at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 77
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 110
... (missing steps in my classes) ...
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at OrchardCore.Apis.GraphQL.GraphQLMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService, IAuthenticationService authenticationService, ISchemaFactory schemaService, IDocumentWriter documentWriter)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at It.Csc.OrchardCorePA.Content.Summary.SummaryStartupFilter.<>c.<<Configure>b__1_1>d.MoveNext() in D:\rilasci\OrchardCorePA.Citizen.Services\src\Modules\It.Csc.OrchardCorePA.Content.Summary\SummaryStartupFilter.cs:line 21
--- End of stack trace from previous location ---
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
HEADERS
=======
Accept: application/json
Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVG9Eb2N1bWVudC5Kd3QiLCJhdWQiOiJIaWRlIiwiaXNzIjoiVG9Eb2N1bWVudCIsImV4cCI6MTc0NTQxMDU3MCwibmJmIjoxNzQ1NDA5OTcwfQ.XaDLjsnoGd4mK-h4b0HkIozaYdXtgF8tJNmwsEcPHAY
Content-Length: 2771
Content-Type: application/json; charset=utf-8
Host: ....
No inner exception.
I execute PuppeteerSharp with this code:
...
var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
using var page = await browser.NewPageAsync();
await page.SetContentAsync(writer.ToString(), new NavigationOptions { WaitUntil = new[] { WaitUntilNavigation.Load }});
//I don't know if necessary
//var result = await page.GetContentAsync();
await page.EvaluateExpressionHandleAsync("document.fonts.ready");
...