cdp.Target: CreateBrowserContext: rpc error: Not allowed. (code = -32000)
gulien opened this issue ยท comments
Hello again,
The following error is thrown in Travis CI and has also been reported here gotenberg/gotenberg#15:
cdp.Target: CreateBrowserContext: rpc error: Not allowed. (code = -32000)
It happens here in my code: https://github.com/thecodingmachine/gotenberg/blob/master/internal/pkg/printer/html.go#L55
Google Chrome is installed in a Debian/stretch Docker image: https://github.com/thecodingmachine/gotenberg/blob/master/build/base/Dockerfile#L33.
And it is launched with PM2 using those options:
"--no-sandbox",
"--headless",
"--remote-debugging-port=9222",
"--disable-gpu",
"--disable-translate",
"--disable-extensions",
"--disable-background-networking",
"--safebrowsing-disable-auto-update",
"--disable-sync",
"--disable-default-apps",
"--hide-scrollbars",
"--metrics-recording-only",
"--mute-audio",
"--no-first-run",
๐ค I have now idea why it is happening. I cannot reproduce it locally (macOS with Docker) as those commands works as expected:
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:3
$ curl --request POST \
--url http://localhost:3000/convert/html \
--header 'Content-Type: multipart/form-data' \
--form files=@index.html \
> result.pdf
Thank you! ๐
I suspect this might be a Chrome version issue. In fact, I'm a bit surprised it works for you locally. At least historically, a browser context could not be created from a Page
-endpoint. Instead, you had to connect to the Browser
-endpoint (available via /json/version
).
There's an example of using the browser endpoint in the incognito example, basically you'd change thecodingmachine/gotenberg/internal/pkg/printer/html.go#L41-L52 with:
Lines 23 to 35 in 1dba954
Does making this change fix the issue?
Travis CI is now working as expected ๐ thank you for the quick answer!
Glad to hear, no problem ๐!