Node-SocketIO.Error.Log

Hi all. I was exploring the log files in frappe-bench/logs folder & discovered multiple node-sockerio.error.log files, each with over 500,000 lines in them. The contents in the file list this over & over:
SyntaxError: Unexpected token ‘.’
6 at wrapSafe (internal/modules/cjs/loader.js:915:16)
7 at Module._compile (internal/modules/cjs/loader.js:963:27)
8 at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
9 at Module.load (internal/modules/cjs/loader.js:863:32)
10 at Function.Module._load (internal/modules/cjs/loader.js:708:14)
11 at Module.require (internal/modules/cjs/loader.js:887:19)
12 at require (internal/modules/cjs/helpers.js:74:18)
13 at Object. (/home/admin/frappe-bench/apps/frappe/node_modules/@redis/client/dist/index.js:18:18)
14 at Module._compile (internal/modules/cjs/loader.js:999:30)
15 at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
16 /home/admin/frappe-bench/apps/frappe/node_modules/@redis/client/dist/lib/client/index.js:35
17 modules: extensions?.modules,
18 ^

How can this be corrected?

This sounds like a Node version problem.
What is the output of node --version?
Are you using NVM? If so, it may not be aliasing the correct version of Node for the socketio process. nvm alias node {version} will fix this, run bench restart after that.

Node v21.7.1

As for nvm being installed on my Ubuntu server, I don’t believe so. I ran a script I found to check if it is installed & it reported back that it isn’t.

if [ -d "${HOME}/.nvm/.git" ]; then echo "nvm installed"; else echo "nvm not installed"; fi

Try downgrading (via nvm) to the referenced version of node for your Frappe major version, which should be 18 or 20. I have been using 20 in all 14 and 15 setup recently without issue.

Thanks for the insight. I did install nvm then installed node v20.0.0. I also followed your previous example & after installing node v20 ran nvm alias node 20.0.0 then bench restart. Unfortunately, when running bench restart, that generated a spawn error.

frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)
frappe-bench-web:frappe-bench-frappe-web: started
ERROR: sudo supervisorctl restart frappe-bench-web:
subprocess.CalledProcessError: Command ‘sudo supervisorctl restart frappe-bench-web:’ returned non-zero exit status 7

I also still have the node-socketio.error.log growing exponentially.

This is the big clue, the actual node version that is trying to run this is ancient.

Optional Chaining has been around a long time but it’s either breaking because of this operator or because of something in how its set up.

Did you run bench setup requirements after changing the node version? You will also have to install yarn.

I’m not at all familiar with the chaining you’re referencing. When I did the installation I just followed a basic set of installation instructions then changed it from development to production and later on ran a couple updates. At one point after an update, error messages appeared complaining about the version of Node which stated it needed to be updated. I do not recall all the details any longer as it was a few months ago. I did notice however yesterday the version of Node running as my Ubuntu default login was the version 21.x.x but when I switched to the user I created to install ERPNext, the version is v18.19.1.

I did not run “bench setup requirements” after changing node versions but will. Yarn was installed during the installation of ERPNext.

Optional Chaining Operator

Frappe is likely not using the correct version of Node. Yarn is installed per-node version, not as a global CLI (which is goofy but a thing).

  1. Install the latest LTS version of node 20 (nvm install 20 --lts)
  2. Use that version (nvm use 20)
  3. Alias that version (nvm alias node 20)
  4. Install yarn (npm install yarn -g)
  5. Setup requirements (bench setup requirements --node)

same errors… increases in size by almost 2k every second

/home/admin/frappe-bench/apps/frappe/node_modules/@redis/client/dist/lib/client/index.js:35 2 modules: extensions?.modules, 3 ^ 4
5 SyntaxError: Unexpected token ‘.’ 6 at wrapSafe (internal/modules/cjs/loader.js:915:16)
7 at Module._compile (internal/modules/cjs/loader.js:963:27)
8 at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
9 at Module.load (internal/modules/cjs/loader.js:863:32)
10 at Function.Module._load (internal/modules/cjs/loader.js:708:14)
11 at Module.require (internal/modules/cjs/loader.js:887:19)
12 at require (internal/modules/cjs/helpers.js:74:18)
13 at Object. (/home/admin/frappe-bench/apps/frappe/node_modules/@redis/client/dist/index.js:18:18)
14 at Module._compile (internal/modules/cjs/loader.js:999:30)
15 at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
16 /home/admin/frappe-bench/apps/frappe/node_modules/@redis/client/dist/lib/client/index.js:35
17 modules: extensions?.modules

I recall now why node v21 was installed. During the initial installation of ERPNext, I chose to install the hrms app. When that was installed, that is when the error occured which related indicatd the version of node needed to be updated. I updated it without doing anything farther. So, I installed a brand new ERPNext setup on a separate box WITHOUT the hrms app then set it to production. There is still a node-socketio.error.log being generated but it seems it only increases in size either after a server reboot or issuing a “bench restart” command. It does not continue to increase exponentially as in the first installation.

I do however still have the same spawn error when performing bench restart.

This is some updated information regarding these node-sockerio.error.log files.
The box that is exhibiting this is running in a Ubuntu VM hosted on a Windows 2019 server box. This was chosen initially due to the box being a dedicated HPE server w/Xeon CPU & SAS drive arrays.
Since installing ERPNext onto a separate Intel based box w/Ubuntu v22.04.4 server, this issue does not exist. I wiped the VM, on the Windows box, re-created the VM & installed ERPNext in the same manner as I did with the Ubuntu box. The problem with the node-sockerio.error.log is back in full force & that is without have performed anything other than the installation & first login as the administrator user.
Do you suppose there is some incompatiblaties with this running as a VM on a Windows box?

I finally worked out the “cure” for the ever increasing isize of the node-socketio.error.log file in the frappe-next/logs folder. If you followed the instructions for installing ERPNext, you created a frappe user which is the user you switch to when installing ERPNext. Node, nvm & npm gets installed early on & typically this is calling for node v18 to be installed. While being recommended to install node v18, in Ubuntu v22.04 server, node v12.x is happens to be the default version installed by default during the ubuntu system installation for the default user. This I discovered is what is causing the problem, two different versions of node running & clashing.
The fix is simple, make sure you’re logged in as the default user (not root), execute sudo apt remove node then run the following:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile
nvm install 18

This will match both versions of node which eliminated the gigabytes of error log files that run rampant.