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

[Bug]: Timeout while attempting to connect to Firefox

Open AFract opened this issue 2 months ago • 3 comments

Hello,

I am trying to use a headless instance of Firefox to generate some PDF based on precomputed HTML.

Puppeteer 20.2.2 works well (at least on my development machine, in a process hosted in IIS Express) with Edge and Chrome, but for Firefox (which is the browser I'll have to use, unfortunately) it fails with this exception:

 ---> PuppeteerSharp.ProcessException: Timed out after 30000 ms while trying to connect to Base!
   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

Here is the repro :

            await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions // This line throws the exception
            {
                ExecutablePath = @"C:\Program Files\Mozilla Firefox\firefox.exe",
                Browser = SupportedBrowser.Firefox,
                Headless = true,
            });

            // Open new browser page
            await using var page = await browser.NewPageAsync();

            // Load html in off screen browser
            await page.SetContentAsync(html, new NavigationOptions()
            {
                WaitUntil = [WaitUntilNavigation.DOMContentLoaded]
            });

            var pdfBytes = await page.PdfDataAsync();

I have tried to start manually firefox, or to remove the "headless", just in case, it does not change anything. I know Pupeteer does something, since when I can see several "Firefox.exe" processes appear in my task manager when I invoke my code, and disappear a few seconds later.

Environment : Firefox 143.0.1, Puppeteer 20.2.2, Windows 10, process running in IIS Express (without debug).

Thank you :)

AFract avatar Sep 22 '25 08:09 AFract