"Failed to launch puppeteer" error after deploying a NodeJS app in cflinux3
search cancel

"Failed to launch puppeteer" error after deploying a NodeJS app in cflinux3

book

Article ID: 298318

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

You migrated an existing nodeJS app to another stack and you noticed the app fails to start due to shared libraries. Shared objects libraries can not be vendored.

In the following example, a nodeJS app using a vendored puppeteer library but the putppeteer library is dependent on libnns3.so lib. This results in the following error:
 

2021-09-16T12:09:55.552-04:00 [APP/PROC/WEB/0] [ERR] 2021-09-16 16:09:55.552+0000 org{am_dt} ERROR [APP_NAME=nodejs-sample-app, APP_VERSION=d73499f3-3544-4dd8-88f0-37107ba77bdd, APP_URL=nodejs-sample-app.example.com,MY_SPACE=dev, INSTANCE_ID=0] MESSAGE=[Error: Failed to launch chrome! 
2021-09-16T12:09:55.552-04:00 [APP/PROC/WEB/0] [ERR] chrome/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory 2021-09-16T12:09:55.552-04:00 [APP/PROC/WEB/0] [ERR] TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
2021-09-16T12:09:55.552-04:00 [APP/PROC/WEB/0] [ERR] ] 2021-09-16T12:09:55.554-04:00 [APP/PROC/WEB/0] [ERR] (node:126) UnhandledPromiseRejectionWarning: Error: Failed to launch puppeteer


For apps deployed in Cloud Foundry, its best practice to follow 12 factor app
 

"Twelve-factor apps also do not rely on the implicit existence of any system tools. Examples include shelling out to ImageMagick or curl. While these tools may exist on many or even most systems, there is no guarantee that they will exist on all systems where the app may run in the future, or whether the version found on a future system will be compatible with the app. If the app needs to shell out to a system tool, that tool should be vendored into the app."



Environment

Product Version: 2.11

Resolution

Shared objects libraries can not be vendored. Here are two ways you can resolve this issue:

Option 1

ssh into the app container and install the shared libraries:

$ cf ssh <app-name>
$ sudo apt-get install -y libnss3-tools


Note: You may need to install the shared libraries every time you deploy the app.

Option 2

Deploy your app with two buildpacks:


Note: apt buildpack is not one of  the TAS for VMs system buildpacks. You need to install apt buildpack since it does not come with the TAS for VMs installation. apt buildpack is also considered a third party buildpack which VMWare Tanzu Support does not officially support. 

For more information on Multi-buildpack, refer to Cloud Foundry Multi-buildpack.