puppeteer: Chromium fails to start when calling puppeteer.launch() in Azure App Service
The line const chromeProcess = childProcess.spawn(chromeExecutable, chromeArguments, {});
in puppeteer/lib/Launcher.js
is failing for me.
Line numbers in this stack trace might be off since I added logging to my local Launcher.js
{ Error: spawn UNKNOWN
at exports._errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:317:11)
at Object.exports.spawn (child_process.js:491:9)
at Function.launch (D:\home\site\wwwroot\node_modules\puppeteer\lib\Launcher.js:86:40)
at Function.launch (D:\home\site\wwwroot\node_modules\puppeteer\lib\Puppeteer.js:25:21)
at __dirname (D:\home\site\wwwroot\server.js:39:29)
...
Environment: Azure App Service OS version: Microsoft Windows Server 2012 x64 Node: 8.1.4
chromeExecutable
is D:\home\site\wwwroot\node_modules\puppeteer\.local-chromium\win32-496140\chrome-win32\chrome.exe
When I try to run chrome.exe
from the command line inside the App Service I get
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
When running locally (Windows 10 x64) I don’t have this issue.
It seems this is related to the redistributables of C/C++ installed (or not) on the system https://answers.microsoft.com/en-us/windows/forum/windows_10-performance/the-google-chrome-is-not-working-in-my-windows-10/8ecaed7a-e6e1-4097-970f-d32aaba5ec6f https://bugs.chromium.org/p/chromium/issues/detail?id=380228
Is there an alternate version of chrome.exe
that I can try uploading to see if it resolves the issue?
Thanks!
Edit – It seems using this package in the Azure App Service sandbox might not be an option because of security / processing limitations.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 18
- Comments: 15 (1 by maintainers)
had same problem and tried to use linux as ops (while you create your web app or web app for container select linux instead of windows ) this solved first part of the problem (it took you out of sandbox restrictions) after that select built -in runtime for your app (in my case selected node 8.x) and deployed it.
at that point I have to install missing necessary shared library dependencies for chrome.
Running Puppeteer in Docker
just use web ssh and install those deps maually
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&\ sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' &&\ apt-get update &&\ apt-get install -y google-chrome-unstable
now everything ready to use Headless Chrome with Puppeteer but one more gotcha in your code need to be done, chrome has to be launched with no-sanbox flags
let browser = await puppeteer.launch({ args: [ '--no-sandbox', '--disable-setuid-sandbox' ] });
this is the only workaround i could find, hope that helps to someone
I am getting the same issue while launching puppeteer.
{ Error: spawn UNKNOWN }
Using Azure functions and Node 6.5.
@kaushik-sundar This is where I was hoping to test functionality once support for Node 6.5 landed (which it has now). I’m not surprised some of the same issues appear in Azure Functions as well.
I’ve seen that many of the headless chrome projects in development had explicitly stated they support AWS Lambda but I don’t know enough about headless Chrome, the compatibility ecosystem or Lambda to understand what needs to be done to support that environment or what needs to change to support Azure (which some of the libraries have stated is on their roadmap).
My use-case right now is a simple API for generating PDFs in a consistent way from a block of HTML and CSS (something that is difficult or impossible using browser based methods - like jsPDF).
Anybody was able to start Puputter / Chrome from Azure App Services or Azure Functions? I am getting the same spawn error. Thanks!
Below is the log: