ReferenceError: TextEncoder is not defined
What version were you using?
https://github.com/LearningLocker/learninglocker/releases/tag/v7.1.1
What steps can we follow to reproduce the behaviour?
Basically the steps in https://learninglocker.atlassian.net/wiki/spaces/DOCS/pages/622596/Installing (documentation update of Aug 04, 2022).
More specifically...
Using Ubuntu 18.04.6 LTS:
-
curl -o- -L https://raw.githubusercontent.com/LearningLocker/deploy/master/deployll.sh > deployll.sh && bash deployll.sh -
sudo su learninglocker -
pm2 statusdisplays that xAPI "errored" (see screenshot below of output table) -
pm2 logs xAPIinclude the following error for both4|xAPIand5|xAPIrepeated times (e.g. even loggingpm2 logs --lines 4000)
5|xAPI | ReferenceError: TextEncoder is not defined
5|xAPI | at Object.<anonymous> (/usr/local/learninglocker/releases/ll-20221124-5fec948a823e372e740df521aa3684c8df1dcba7/xapi/node_modules/mongodb-connection-string-url/node_modules/whatwg-url/lib/encoding.js:2:21)
5|xAPI | at Module._compile (internal/modules/cjs/loader.js:778:30)
5|xAPI | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
5|xAPI | at Module.load (internal/modules/cjs/loader.js:653:32)
5|xAPI | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
5|xAPI | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
5|xAPI | at Module.require (internal/modules/cjs/loader.js:692:17)
5|xAPI | at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39)
5|xAPI | at require (internal/modules/cjs/helpers.js:25:18)
5|xAPI | at Object.<anonymous> (/usr/local/learninglocker/releases/ll-20221124-5fec948a823e372e740df521aa3684c8df1dcba7/xapi/node_modules/mongodb-connection-string-url/node_modules/whatwg-url/lib/url-state-machine.js:5:34)
5|xAPI | 2022-11-25 10:07:48:095 - error: Failed Mongo connection: no primary found in replicaset or invalid replica set name
5|xAPI | 2022-11-25 10:07:48:098 - error: Failed initial mongo connection: Too many retries
What is the actual behaviour?

What is the expected behavior?
The expected behavior is for all processes to start with an "online" status.
Is there any additional information that will help us replicate/understand the problem?
I did some digging and it seems to be related with node's version: https://github.com/jsdom/whatwg-url/issues/209 https://github.com/Automattic/mongoose/issues/10638
The only thing that fixed it for me was:
- Following this suggestion https://stackoverflow.com/a/69287561/20588311
- Changing from the installed node version (10.24.1; i.e. the one that learning-locker installed during
deployll.shexecution) to node 16.8.1. - Running
yarn
It helped me:
https://www.youtube.com/watch?v=EJF_U6wIh8M
There is a solution in this issue #1625 Adding a "missing" require.