RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.84k stars 10.76k forks source link

Wrong NodeJS version in package bundle: app/bundle/.node_version.txt #30515

Open mhaluska opened 1 year ago

mhaluska commented 1 year ago

Description:

Wrong NodeJS version in package bundle: app/bundle/.node_version.txt

Expected behavior:

NodeJS v14.21.3 in app/bundle/.node_version.txt

Actual

Not existing NodeJS version v14.21.4 in app/bundle/.node_version.txt in tar bundle 6.3.8 and 6.4.0

…
+ mkdir -p src/app src/local
+ curl -LS https://releases.rocket.chat/6.3.8/download -o /tmp/rocket-chat.tar.gz
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100   132  100   132    0     0    214      0 --:--:-- --:--:-- --:--:--   214
100  240M  100  240M    0     0  75.1M      0  0:00:03  0:00:03 --:--:--  110M
+ tar xzf /tmp/rocket-chat.tar.gz -C src/app
+ rm -f /tmp/rocket-chat.tar.gz
+ cat src/app/bundle/.node_version.txt
+ NODE_VERSION=v14.21.4
+ curl -LS https://nodejs.org/dist/v14.21.4/node-v14.21.4-linux-x64.tar.gz -o /tmp/node.tar.gz
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
[100 12159](tel:100 12159)    0 12159    0     0  65241      0 --:--:-- --:--:-- --:--:-- 65370
+ tar xzf /tmp/node.tar.gz -C src/local --strip 1
tar: invalid magic
tar: short read
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

Server Setup Information:

Client Setup Information

Relevant logs:

Gitlab job: https://gitlab.haluska.dev/containers/rocket-chat/-/jobs/2872

Slug-V commented 1 year ago

probably related: meteor/meteor#12732

v-a14 commented 1 year ago

probably related: meteor/meteor#12732

Have you fix the issue ?

Slug-V commented 1 year ago

Unfortunately, no.

My instance is stuck in 6.2.12 because this 14.21.4 problem exists in each of 6.3+.
So this will die when 6.2 reaches its EOL.

note: I'm using tar from Gentoo ebuild (edit: this is not official but from overlay. I downloaded this about 10 years ago and incrementally hand-adjusted to newer versions). So it may have some difference. If I realize it, I'll open a new issue.

v-a14 commented 1 year ago

Unfortunately, no.

My instance is stuck in 6.2.12 because this 14.21.4 problem exists in each of 6.3+.
So this will die when 6.2 reaches its EOL.

note: I'm using tar from Gentoo ebuild (edit: this is not official but from overlay. I downloaded this about 10 years ago and incrementally hand-adjusted to newer versions). So it may have some difference. If I realize it, I'll open a new issue.

Can you please explain me, what I have to do in this, actually I am very new to open source, but I have knowledge of js, node, and react.

Slug-V commented 1 year ago

@v-a14 I'm very confused about rocketchat-meteor(or, current RC uses raw Meteor?), so the first question is...

  1. inspect RC about how rocketchat-meteor corresponds to upstream meteor
  2. check whether the latest rocketchat-meteor uses meteor 2.13.3+ or not

If the answer is NO, updating Meteor or backporting the change (and checking whether it makes a difference or not) is needed. If it's YES, inspecting how the installation tarball is made(CD pipeline?) is needed.

edit: I noticed star.json says "meteorRelease": "METEOR@2.13.3". Why is this happening?🤔

Slug-V commented 1 year ago

I tried:

  1. download the tarball from https://releases.rocket.chat/latest/download
  2. extract it and cd to bundle directory
  3. grep -l -F 14.21.4 -r1 ./

returned files:

./.node_version.txt
./star.json
./README
./programs/web.browser/dynamic/app/utils/rocketchat.info.js
./programs/web.browser.legacy/dynamic/app/utils/rocketchat.info.js
./programs/server/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/core-js/.meteor-last-rebuild-version.json
./programs/server/npm/node_modules/meteor/babel-compiler/node_modules/resolve/.meteor-last-rebuild-version.json
./programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/.meteor-last-rebuild-version.json
./programs/server/npm/node_modules/meteor/url/node_modules/core-js/.meteor-last-rebuild-version.json
./programs/server/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/core-js/.meteor-last-rebuild-version.json
./programs/server/app/app.js
./server/.bundle_version.txt

Patching these files may solve this.

Slug-V commented 1 year ago

Finally, I got a temporal solution:

patch file for my Gentoo ```patch diff '--color=auto' -uprN ./.node_version.txt ./bundle2/.node_version.txt --- ./.node_version.txt 2023-11-02 12:33:00.000000000 +0900 +++ ./.node_version.txt 2023-11-10 20:12:53.580139845 +0900 @@ -1 +1 @@ -v14.21.4 +v14.21.3 diff '--color=auto' -uprN ./README ./bundle2/README --- ./README 2023-11-02 12:33:00.000000000 +0900 +++ ./README 2023-11-10 20:12:53.580139845 +0900 @@ -1,5 +1,5 @@ This is a Meteor application bundle. It has only one external dependency: -Node.js v14.21.4. To run the application: +Node.js v14.21.3. To run the application: $ (cd programs/server && npm install) $ export MONGO_URL='mongodb://user:password@host:port/databasename' diff '--color=auto' -uprN ./programs/server/app/app.js ./programs/server/app/app.js --- ./programs/server/app/app.js 2023-11-02 12:33:06.000000000 +0900 +++ ./programs/server/app/app.js 2023-11-10 20:12:53.641138872 +0900 @@ -102136,7 +102136,7 @@ exports.Info = { "version": "6.4.5", "build": { "date": "2023-11-02T03:32:16.476Z", - "nodeVersion": "v14.21.4", + "nodeVersion": "v14.21.3", "arch": "x64", "platform": "linux", "osRelease": "5.15.0-1050-azure", diff '--color=auto' -uprN ./programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/.meteor-last-rebuild-version.json ./programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/.meteor-last-rebuild-version.json --- ./programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/.meteor-last-rebuild-version.json 2023-11-02 12:33:22.000000000 +0900 +++ ./programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/.meteor-last-rebuild-version.json 2023-11-10 20:12:53.580139845 +0900 @@ -2,7 +2,7 @@ "platform": "linux", "arch": "x64", "versions": { - "node": "14.21.4", + "node": "14.21.3", "v8": "8.4.371.23-node.88", "uv": "1.42.0", "zlib": "1.2.11", diff '--color=auto' -uprN ./programs/server/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/core-js/.meteor-last-rebuild-version.json ./programs/server/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/core-js/.meteor-last-rebuild-version.json --- ./programs/server/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-02 12:33:09.000000000 +0900 +++ ./programs/server/npm/node_modules/meteor/ecmascript-runtime-client/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-10 20:12:53.580139845 +0900 @@ -2,7 +2,7 @@ "platform": "linux", "arch": "x64", "versions": { - "node": "14.21.4", + "node": "14.21.3", "v8": "8.4.371.23-node.88", "uv": "1.42.0", "zlib": "1.2.11", diff '--color=auto' -uprN ./programs/server/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/core-js/.meteor-last-rebuild-version.json ./programs/server/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/core-js/.meteor-last-rebuild-version.json --- ./programs/server/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-02 12:33:11.000000000 +0900 +++ ./programs/server/npm/node_modules/meteor/ecmascript-runtime-server/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-10 20:12:53.580139845 +0900 @@ -2,7 +2,7 @@ "platform": "linux", "arch": "x64", "versions": { - "node": "14.21.4", + "node": "14.21.3", "v8": "8.4.371.23-node.88", "uv": "1.42.0", "zlib": "1.2.11", diff '--color=auto' -uprN ./programs/server/npm/node_modules/meteor/url/node_modules/core-js/.meteor-last-rebuild-version.json ./programs/server/npm/node_modules/meteor/url/node_modules/core-js/.meteor-last-rebuild-version.json --- ./programs/server/npm/node_modules/meteor/url/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-02 12:33:21.000000000 +0900 +++ ./programs/server/npm/node_modules/meteor/url/node_modules/core-js/.meteor-last-rebuild-version.json 2023-11-10 20:12:53.580139845 +0900 @@ -2,7 +2,7 @@ "platform": "linux", "arch": "x64", "versions": { - "node": "14.21.4", + "node": "14.21.3", "v8": "8.4.371.23-node.88", "uv": "1.42.0", "zlib": "1.2.11", diff '--color=auto' -uprN ./programs/web.browser/dynamic/app/utils/rocketchat.info.js ./programs/web.browser/dynamic/app/utils/rocketchat.info.js --- ./programs/web.browser/dynamic/app/utils/rocketchat.info.js 2023-11-02 12:33:03.000000000 +0900 +++ ./programs/web.browser/dynamic/app/utils/rocketchat.info.js 2023-11-10 20:12:53.580139845 +0900 @@ -1,2 +1,2 @@ -function module(e,a){a.Info={version:"6.4.5",build:{date:"2023-11-02T03:29:31.800Z",nodeVersion:"v14.21.4",arch:"x64",platform:"linux",osRelease:"5.15.0-1050-azure",totalMemory:7268773888,freeMemory:140828672,cpus:2},marketplaceApiVersion:"1.41.0-alpha.312",commit:{hash:"edb6cae7408db9f0bf82826b7a82c94780e84e8c",date:"Wed Nov 1 21:15:43 2023 +0000",author:"rocketchat-github-ci",subject:"Release 6.4.5",tag:"6.4.5",branch:"HEAD"}}} +function module(e,a){a.Info={version:"6.4.5",build:{date:"2023-11-02T03:29:31.800Z",nodeVersion:"v14.21.3",arch:"x64",platform:"linux",osRelease:"5.15.0-1050-azure",totalMemory:7268773888,freeMemory:140828672,cpus:2},marketplaceApiVersion:"1.41.0-alpha.312",commit:{hash:"edb6cae7408db9f0bf82826b7a82c94780e84e8c",date:"Wed Nov 1 21:15:43 2023 +0000",author:"rocketchat-github-ci",subject:"Release 6.4.5",tag:"6.4.5",branch:"HEAD"}}} //# sourceMappingURL=/dynamic/app/utils/f0ed5a201b1d43e35e5fcaf6b9f4987959477a1e.map diff '--color=auto' -uprN ./programs/web.browser.legacy/dynamic/app/utils/rocketchat.info.js ./programs/web.browser.legacy/dynamic/app/utils/rocketchat.info.js --- ./programs/web.browser.legacy/dynamic/app/utils/rocketchat.info.js 2023-11-02 12:33:05.000000000 +0900 +++ ./programs/web.browser.legacy/dynamic/app/utils/rocketchat.info.js 2023-11-10 20:12:53.580139845 +0900 @@ -1,2 +1,2 @@ -function module(e,a){a.Info={version:"6.4.5",build:{date:"2023-11-02T03:31:10.158Z",nodeVersion:"v14.21.4",arch:"x64",platform:"linux",osRelease:"5.15.0-1050-azure",totalMemory:7268773888,freeMemory:143790080,cpus:2},marketplaceApiVersion:"1.41.0-alpha.312",commit:{hash:"edb6cae7408db9f0bf82826b7a82c94780e84e8c",date:"Wed Nov 1 21:15:43 2023 +0000",author:"rocketchat-github-ci",subject:"Release 6.4.5",tag:"6.4.5",branch:"HEAD"}}} +function module(e,a){a.Info={version:"6.4.5",build:{date:"2023-11-02T03:31:10.158Z",nodeVersion:"v14.21.3",arch:"x64",platform:"linux",osRelease:"5.15.0-1050-azure",totalMemory:7268773888,freeMemory:143790080,cpus:2},marketplaceApiVersion:"1.41.0-alpha.312",commit:{hash:"edb6cae7408db9f0bf82826b7a82c94780e84e8c",date:"Wed Nov 1 21:15:43 2023 +0000",author:"rocketchat-github-ci",subject:"Release 6.4.5",tag:"6.4.5",branch:"HEAD"}}} //# sourceMappingURL=/dynamic/app/utils/b17969fc3994a91bae5d03d2a1477ab1ba0f6c95.map diff '--color=auto' -uprN ./server/.bundle_version.txt ./server/.bundle_version.txt --- ./server/.bundle_version.txt 2023-11-02 12:33:00.000000000 +0900 +++ ./server/.bundle_version.txt 2023-11-10 20:12:53.643138841 +0900 @@ -1 +1 @@ -14.21.4.3 +14.21.3.3 diff '--color=auto' -uprN ./star.json ./star.json --- ./star.json 2023-11-02 12:34:22.000000000 +0900 +++ ./star.json 2023-11-10 20:12:53.580139845 +0900 @@ -19,7 +19,7 @@ } ], "meteorRelease": "METEOR@2.13.3", - "nodeVersion": "14.21.4", + "nodeVersion": "14.21.3", "npmVersion": "6.14.17", "gitCommitHash": "edb6cae7408db9f0bf82826b7a82c94780e84e8c" } ```

what I did:

  1. extract the latest(6.4.5) tar and copy the bundle folder into bundle2
  2. cd to bundle2
  3. grep -l -F 14.21.4 -r1 ./
  4. chmod -v 644 to all found files (edit: you can use xargs)
  5. sed -i -e s/14.21.4/14.21.3/g <files> to all found files (edit: you can use xargs)
    • (edit: also add sed -i -e s/1.4.0/1.5.0/g ./programs/server/npm/node_modules/gc-stats/package.json to avoid #29600 in 6.6.0)
  6. cd ../
  7. diff -uprN ./bundle ./bundle2 > fix-nodejs-version.patch
  8. open the file and correct filepath
    • in case my ebuild: remove ./bundle or ./bundle2 from patching file path
    • generally: rename ./bundle2 into ./bundle
  9. patch it and try to install
    • in case my ebuild: I used /etc/portage/patches

This workaround seems to be needed when every Rocket.Chat update, so this issue stays alive until Rocket.Chat starts using more newer nodejs (edit: see #29658).

Slug-V commented 9 months ago

In 6.6.0, patching is fine, but won't build because one (potentially some) node.js package cannot be downloaded (returns 403).

> gc-stats@1.4.0 install /var/tmp/portage/www-apps/rocketchat-server-6.6.0/work/bundle/programs/server/npm/node_mod
ules/gc-stats
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! install response status 403 Forbidden on https://node-binaries.s3.amazonaws.com/gcstats/v1.4.0/Re
lease/node-v83-linux-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for gc-stats@1.4.0 and node@14.21.3 (node-v83 ABI, glibc) (fal
ling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 403 Forbidden on https://node-binaries.s3.amazonaws.com/gcstats/v1.4.0/
Release/node-v83-linux-x64.tar.gz

I think this should be rehappened #29600 issue, regression in 6.6.0.