Some errors when using puppeteer on Linux


Error 1:

(node:16167) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): Error: Failed to launch chrome!
/home/nodejs3/node_modules/puppeteer/.local-chromium/linux-555668/chrome-linux/c
hrome: error while loading shared libraries: libXss.so.1: cannot open shared obj
ect file: No such file or directory

Fix:

[root@tutorialspots ~]# yum install libXScrnSaver
Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00
epel/x86_64/metalink                                     |  20 kB     00:00
epel                                                     | 3.2 kB     00:00
extras                                                   | 3.4 kB     00:00
mariadb                                                  | 2.9 kB     00:00
nginx                                                    | 2.9 kB     00:00
nodesource                                               | 2.5 kB     00:00
remi-php71                                               | 2.9 kB     00:00
remi-safe                                                | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/11): epel/x86_64/group_gz                               |  88 kB   00:00
(2/11): base/7/x86_64/group_gz                             | 166 kB   00:00
(3/11): epel/x86_64/updateinfo                             | 933 kB   00:00
(4/11): mariadb/primary_db                                 |  48 kB   00:00
(5/11): extras/7/x86_64/primary_db                         | 147 kB   00:00
(6/11): nodesource/x86_64/primary_db                       |  53 kB   00:00
(7/11): remi-php71/primary_db                              | 218 kB   00:00
(8/11): epel/x86_64/primary                                | 3.5 MB   00:01
(9/11): remi-safe/primary_db                               | 1.2 MB   00:01
(10/11): updates/7/x86_64/primary_db                       | 2.0 MB   00:03
(11/11): base/7/x86_64/primary_db                          | 5.9 MB   00:11
Determining fastest mirrors
 * base: mirror.es.its.nyu.edu
 * epel: mirror.grid.uchicago.edu
 * extras: bay.uchicago.edu
 * remi-php71: repo1.dal.innoscale.net
 * remi-safe: repo1.dal.innoscale.net
 * updates: linux.mirrors.es.net
epel                                                                12584/12584
Resolving Dependencies
--> Running transaction check
---> Package libXScrnSaver.x86_64 0:1.2.2-6.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch           Version                Repository    Size
================================================================================
Installing:
 libXScrnSaver         x86_64         1.2.2-6.1.el7          base          24 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 40 k
Is this ok [y/d/N]: y
Downloading packages:
libXScrnSaver-1.2.2-6.1.el7.x86_64.rpm                     |  24 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libXScrnSaver-1.2.2-6.1.el7.x86_64                           1/1
  Verifying  : libXScrnSaver-1.2.2-6.1.el7.x86_64                           1/1

Installed:
  libXScrnSaver.x86_64 0:1.2.2-6.1.el7

Error 2:

(node:18224) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): Error: Failed to launch chrome!
/home/nodejs3/node_modules/puppeteer/.local-chromium/linux-555668/chrome-linux/c
hrome: error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open
 shared object file: No such file or directory

Fix:

yum install pango libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXrandr GConf2 alsa-lib atk gtk3 -y

Error 3:

(node:24393) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): Error: Failed to launch chrome!
[0602/052752.450482:ERROR:zygote_host_impl_linux.cc(88)] Running as root without
 --no-sandbox is not supported. See https://crbug.com/638180.

Fix: Use –no-sandbox

const browser = puppeteer.launch({timeout :0,args:['--no-sandbox']})

Error 4:

(node:32747) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): Error: socket hang up

or

{ Error: socket hang up
    at createHangUpError (_http_client.js:253:15)
    at Socket.socketOnEnd (_http_client.js:345:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNR
ESET' }

Check version:

CentOS Linux release 7.3.1611

Fix:

yum update

Now version is 7.5.1804

[root@tutorialspots ~]# cat /etc/*release*
CentOS Linux release 7.5.1804 (Core)
Derived from Red Hat Enterprise Linux 7.5 (Source)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.5.1804 (Core)
CentOS Linux release 7.5.1804 (Core)
cpe:/o:centos:centos:7

Leave a Reply