LearningLocker / learninglocker

Learning Locker - The Open Source Learning Record Store. Started in 2014.
https://learningpool.com/solutions/learning-record-store-learning-locker/learning-locker-community-overview/
GNU General Public License v3.0
555 stars 276 forks source link

ReferenceError: TextEncoder is not defined #1622

Open etorres07 opened 1 year ago

etorres07 commented 1 year ago

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:

  1. curl -o- -L https://raw.githubusercontent.com/LearningLocker/deploy/master/deployll.sh > deployll.sh && bash deployll.sh
  2. sudo su learninglocker
  3. pm2 status displays that xAPI "errored" (see screenshot below of output table)
  4. pm2 logs xAPI include the following error for both 4|xAPI and 5|xAPI repeated times (e.g. even logging pm2 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?

Screenshot from 2022-11-25 10-45-36

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:

  1. Following this suggestion https://stackoverflow.com/a/69287561/20588311
  2. Changing from the installed node version (10.24.1; i.e. the one that learning-locker installed during deployll.sh execution) to node 16.8.1.
  3. Running yarn
thiagoocortes commented 1 year ago

It helped me:

https://www.youtube.com/watch?v=EJF_U6wIh8M

jybleau commented 1 year ago

There is a solution in this issue #1625 Adding a "missing" require.