Rocket chat 5.1.0 crash on ubuntu 20 , triggered by sharp?

Description

rocket chat crashes on startup, the error seems to be triggered by sharp.

Server Setup Information

  • Version of Rocket.Chat Server: 5.1.0
  • Operating System: ubtunu 20.04 LTS
  • Deployment Method: manual
  • Number of Running Instances: one
  • DB Replicaset Oplog:
  • NodeJS Version: npm 6.14.7, node 14.20.0
  • MongoDB Version: 5.0.11
  • Proxy: haproxy (ssl termination)
  • Firewalls involved: no

Any additional Information

journalctl -fu for the systemd startup:

– Logs begin at Sat 2022-09-03 09:29:03 CEST. –
Sep 03 15:21:06 app7 rocketchat[37351]: at Object. (/opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/constructor.js:8:1)
Sep 03 15:21:06 app7 rocketchat[37351]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
Sep 03 15:21:06 app7 rocketchat[37351]: at Module.Mp._compile (/opt/Rocket.Chat/programs/server/runtime.js:99:23)

Installation following the docs at sharp - High performance Node.js image processing
with

npm install --ignore-scripts=false --foreground-scripts --verbose sharp

npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle !invalid#1~shrinkwrap: !invalid#1
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle !invalid#1~postshrinkwrap: !invalid#1
npm WARN server No description
npm WARN server No repository field.
npm WARN server No license field.

+ sharp@0.30.7
updated 1 package and audited 45 packages in 3.111s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm verb exit [ 0, true ]
npm timing npm Completed in 4373ms
npm info ok

So it looks as if the installation of this “submodule” was successful. I don’t understand why I still see a crash here … Any ideas for further debugging? (Background note: I am not familiar with the details of node.js development)

Thanks, Thommie

Hello, need more exposure to the error - I am not seeing where/what exactly failed in that log.

I am trying to catch the error msg with systemds journalctl, but this may not be the best way for a nodejs application.

Is there a better way of debugging this? (as I said, I am not very familiar with the nodejs environments)

Note: the installation is completely new, no migration from older data sources.

That is fine. It being node app really doesn’t matter at this point. Just add something like -n 200 to actually catch the point of crash.

Hopefully this more informative …

Sep 03 21:24:59 app7 systemd[1]: Started The Rocket.Chat server.
Sep 03 21:25:05 app7 rocketchat[38639]: strict mode: use allowUnionTypes to allow union type keyword at "#/properties/value" (strictTypes)
Sep 03 21:25:07 app7 rocketchat[38639]: /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:218
Sep 03 21:25:07 app7 rocketchat[38639]:       throw error;
Sep 03 21:25:07 app7 rocketchat[38639]:       ^
Sep 03 21:25:07 app7 rocketchat[38639]: Error:
Sep 03 21:25:07 app7 rocketchat[38639]: Something went wrong installing the "sharp" module
Sep 03 21:25:07 app7 rocketchat[38639]: Cannot find module '../build/Release/sharp-linux-x64.node'
Sep 03 21:25:07 app7 rocketchat[38639]: Require stack:
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/sharp.js
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/constructor.js
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/index.js
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/programs/server/npm-require.js
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/programs/server/boot.js
Sep 03 21:25:07 app7 rocketchat[38639]: - /opt/Rocket.Chat/main.js
Sep 03 21:25:07 app7 rocketchat[38639]: Possible solutions:
Sep 03 21:25:07 app7 rocketchat[38639]: - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
Sep 03 21:25:07 app7 rocketchat[38639]: - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
Sep 03 21:25:07 app7 rocketchat[38639]: - Consult the installation documentation: https://sharp.pixelplumbing.com/install
Sep 03 21:25:07 app7 rocketchat[38639]:     at Object.<anonymous> (/opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/sharp.js:34:9)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.Mp._compile (/opt/Rocket.Chat/programs/server/runtime.js:99:23)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.load (internal/modules/cjs/loader.js:950:32)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.Mp.load (/opt/Rocket.Chat/programs/server/runtime.js:46:33)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.require (internal/modules/cjs/loader.js:974:19)
Sep 03 21:25:07 app7 rocketchat[38639]:     at require (internal/modules/cjs/helpers.js:101:18)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Object.<anonymous> (/opt/Rocket.Chat/programs/server/npm/node_modules/sharp/lib/constructor.js:8:1)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.Mp._compile (/opt/Rocket.Chat/programs/server/runtime.js:99:23)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.load (internal/modules/cjs/loader.js:950:32)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Module.Mp.load (/opt/Rocket.Chat/programs/server/runtime.js:46:33)
Sep 03 21:25:07 app7 rocketchat[38639]:     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Sep 03 21:25:07 app7 systemd[1]: rocketchat.service: Main process exited, code=exited, status=1/FAILURE
Sep 03 21:25:07 app7 systemd[1]: rocketchat.service: Failed with result 'exit-code'.
Sep 03 21:25:07 app7 systemd[1]: rocketchat.service: Consumed 8.548s CPU time.

I also did

Sep 03 21:30:02 app7 rocketchat[38923]: - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"

from the server directory and with the user “rocketchat”, but no change.
Info: the application runs inside a lxc container, but that should not make a difference …

Can you share how you installed it in lxc? The steps.

  • plain ubuntu 20.04 LTS
  • added nodesource repo: deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] Index of /node_14.x/ focal main

user rocketchat has this environment

rocketchat@app7:/root$ node -v
v14.20.0

The Application is here: rocketchat@app7: /opt/Rocket.Chat/

The systemd service file:

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
[Service]
ExecStart=/opt/Rocket.Chat/.nvm/versions/node/v14.20.0/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=ROOT_URL=http://localhost:3000
Environment=PORT=3000
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01
Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
[Install]
WantedBy=multi-user.target

Can we add any debugging switches?

Hey I think by now you might have solved this issue.
I was getting the same issue today, solved it using npm rebuild --verbose sharp