Puppeteer/chromium on Mac chronically prompting "accept incoming network connection?"
Asked Answered
T

4

31

I have a node application that uses puppeteer to test a web site. Up until we updated to latest puppeteer 1.12.2 we had no problem.

  1. Node launches puppeteer on timer
  2. On every launch, system asks: "Do you want to the application Chromium.app to accept incoming network connections"

In the Firewall tab of the "Security and Privacy" settings, ACCEPT is specifically set for Chromium. (and we've tried turning it off too) There seems to be no pleasing MacOS on this point.

Any suggestions about how to quiet MacOS and recognize/persist the firewall preference?

Tigre answered 6/2, 2019 at 0:44 Comment(0)
D
16

We were having the same issue after upgrade our puppeteer and MacOS. One solution we have is to instruct puppeteer to use our own Chrome instead of the bundled chromium by specifying the executablePath. Below is a Typescript snippet how we specify it. Same thing if you use vanilla JS.

Sometimes that still is not enough, we have to make headless option false to make it consistently work, which is really annoying.

      /**
       * create a puppeteer 'Browser' object.
       */
      public static createBrowser(): Promise<Browser> {
        return puppeteer.launch({
          // ... other options
          headless: false,
          executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
        });
      }

Hope it also works for you. :-)

Dutiable answered 20/2, 2019 at 13:46 Comment(1)
Puppeteer is only guaranteed to work with the version of chromium it is bundled with. do this at your own riskDyspnea
L
9

Another option is self sign a certificate, follow the instructions in this comment:

https://github.com/GoogleChrome/puppeteer/issues/4752#issuecomment-524086077

Here in more detail how to open the Certificate creator: https://support.apple.com/en-gb/guide/keychain-access/kyca2686/mac)

And then in the root of your repo run:

sudo codesign -s MyCertificateName -f ./node_modules/puppeteer/.local-chromium/mac-674921/chrome-mac/Chromium.app --deep

Lucilla answered 10/9, 2019 at 17:11 Comment(3)
Could not manage to do this option. Hope any tutorial exists on YouTubeHasan
I was struggling to find the certificate assistant. The beginning of this article was helpfulSelfabnegation
This is the right procedure. I've tried it: I had to authorize one last time and now no need to do it each time! Thanks!Gaudet
L
5

1. Find puppeteer location

I found Chromium using the node command and running the following code.

const puppeteer = require('puppeteer');
console.log(puppeteer.executablePath());

2. Codesign puppeteer

The method that worked for me was the one in this answer.

sudo codesign --force --deep --sign - <PATH_FROM_STEP_1>

Note: It still asked for permission the first time after running this command but after that it didn't ask anymore.

Lorinalorinda answered 16/12, 2022 at 23:21 Comment(0)
C
4

In my case it was using a globally installed version of chromium (from playwright). So the following command worked in signing it:

global chromium

sudo codesign --force --deep --sign - ~/Library/Caches/ms-playwright/chromium-*/chrome-mac/Chromium.app

If you don't use a global chromium install, the following might work

local project chromium

sudo codesign --force --deep --sign - ./node_modules/puppeteer/.local-chromium/mac-*/chrome-mac/Chromium.app
Colligate answered 18/10, 2021 at 0:51 Comment(3)
Did not work for my playwright setup unfortunately.Mireillemireles
@Daan see updated answer for local projectColligate
in newer puppeteer versions, chromium is stored in a different module called puppeteer-core. So, adjust the above local script to this sudo codesign --force --deep --sign - ./node_modules/puppeteer-core/.local-chromium/mac-*/chrome-mac/Chromium.appDunno

© 2022 - 2024 — McMap. All rights reserved.