Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headless: false chromium browser is not opening #38

Closed
kaykhan opened this issue Jan 14, 2023 · 8 comments · Fixed by #76
Closed

headless: false chromium browser is not opening #38

kaykhan opened this issue Jan 14, 2023 · 8 comments · Fixed by #76

Comments

@kaykhan
Copy link

kaykhan commented Jan 14, 2023

When i set headless to false to see the chromium browser so i can debug. No browser loads, but the function does finish successfully returning the title. Even tried to remove the headless prop

   const browser = await puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath(),
        ignoreHTTPSErrors: true,
        headless: false
    });

    const page = await browser.newPage();
    await page.goto("https://example.com");
    const pageTitle = await page.title();
    console.log(pageTitle);
    //await browser.close();
   "@sparticuz/chromium": "^109.0.6",
    "puppeteer-core": "^19.4.0",
@Sparticuz
Copy link
Owner

How are you testing this? What OS, environments, etc...?

@kaykhan
Copy link
Author

kaykhan commented Jan 24, 2023

How are you testing this? What OS, environments, etc...?

Node 18
Ubuntu 22

@Sparticuz
Copy link
Owner

Sparticuz commented Jan 26, 2023

If NODE_ENV is set to test it will always run headless, you can try commenting out this line

return true;

@kaykhan
Copy link
Author

kaykhan commented Jan 26, 2023

If NODE_ENV is set to test it will always run headless, you can try commenting out this line

return true;

I wonder if sls invoke local -f runs with NODE_ENV test, i will have to test that theory tomorrow.

@sam09
Copy link

sam09 commented Feb 10, 2023

Hey so I created #53

Setting NODE_ENV and IS_LOCAL together does not run the browser with the local installation and in headless mode.

Is it the desired behaviour or is it a bug?
If it is a bug, would you be accepting a bug fix?

@Sparticuz
Copy link
Owner

Hey so I created #53

Setting NODE_ENV and IS_LOCAL together does not run the browser with the local installation and in headless mode.

Is it the desired behaviour or is it a bug? If it is a bug, would you be accepting a bug fix?

It's a bug, I remember something broke when I refactored puppeteer out of the package. I'll accept a pr. I'd really like to fix all the env variables. I don't see a need for all of them, headless should just be a required variable and the user should know to set it properly.

@Sparticuz
Copy link
Owner

What probably should happen is executablePath should run https://github.com/npm/node-which and return any pre-installed chromium binary, which should allow headful operation. In fact, I think that's what I had altered. Since we use headless.gn to compile chromium, I think it's actually missing the gui.

@edinchev
Copy link

I'm running in to the same issue which is making it difficult to debug what my code is doing since I can't see the Chromium Browser.

Were there any other findings @Sparticuz ?

Node18
Ubuntu22 (WSL2)
Puppeteer - 19.7.2
Chromium - 111

Everything seems to work besides the browser not opening with headless false. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants