hermanho / MMM-GooglePhotos

Display your photos on MagicMirror from Google Photos.
MIT License
162 stars 62 forks source link

Stuck on loading... #182

Closed nhweb closed 5 months ago

nhweb commented 5 months ago

Hello,

I know there are a few posts about this, but none with my error. The installation and configuration went fine, but ist stucks on Loading... In the mm-error.log I could find these:

[11.01.2024 13:08.38.675] [ERROR] (node:9072) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
    at Class.tryToIntitialize (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:151:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[11.01.2024 13:08.38.675] [ERROR] (node:9072) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 68)

In the mm-out.log, there is only this to find:

[11.01.2024 12:02.25.894] [LOG]   Module helper loaded: MMM-GooglePhotos
[11.01.2024 12:02.26.534] [LOG]   Connecting socket for: MMM-GooglePhotos

What to do? The credentials and token exists. Holger

hermanho commented 5 months ago

Which Node.js version is installed?

nhweb commented 5 months ago

Now I have installed v20.11.0. Previously v16.10 was installed.

After the update to v20 I have completly deleted the entire MMM-GooglePhotos directory and did a new installation. Also with this:

cd ~/MagicMirror/modules/MMM-GooglePhotos
npm install --save-dev electron-rebuild
./node_modules/.bin/electron-rebuild   # It could takes dozens sec.
hermanho commented 5 months ago

It should be fine with Node.js v20 and npm install. Does it works if you execute npm install again?

nhweb commented 5 months ago

I executed it now again:

pi@pidisplay:~/MagicMirror/modules/MMM-GooglePhotos $ npm install

up to date, audited 374 packages in 4s

93 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
pi@pidisplay:~/MagicMirror/modules/MMM-GooglePhotos $

But still the same.

hermanho commented 5 months ago

What happens when you execute the following command?

node -e 'fetch("https://httpbin.org/headers").then(r=>r.json()).then(r=>console.log(r))'
nhweb commented 5 months ago

This:

pi@pidisplay:~/MagicMirror/modules/MMM-GooglePhotos $ node -e 'fetch("https://httpbin.org/headers").then(r=>r.json()).then(r=>console.log(r))'
{
  headers: {
    Accept: '*/*',
    'Accept-Encoding': 'br, gzip, deflate',
    'Accept-Language': '*',
    Host: 'httpbin.org',
    'Sec-Fetch-Mode': 'cors',
    'User-Agent': 'node',
    'X-Amzn-Trace-Id': 'Root=1-659ff506-223eee0d09265cfa497ca095'
  }
}
pi@pidisplay:~/MagicMirror/modules/MMM-GooglePhotos $
hermanho commented 5 months ago

The error "ReferenceError: fetch is not defined" should be gone away. Are you starting MM with command npm start in ~/MagicMirror?

nhweb commented 5 months ago

No, unfortunately not. Normally I use pm2 to start and stop. But now I startet with npm start, but with same error:

[11.01.2024 15:11.58.188] [ERROR] (node:16430) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
    at Class.tryToIntitialize (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:151:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
(Use `electron --trace-warnings ...` to show where the warning was created)
[11.01.2024 15:11.58.189] [ERROR] (node:16430) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
hermanho commented 5 months ago

It is likely the old Nodejs v16 is still in your machine and pm2 execute with that one instead of v20. You can try to reboot the machine to see if it is fine. Also, you can create new js file with the following command (or you can put the above fetch script as well) and start by pm2 to check runtime version.

console.log(process.versions.node)
nhweb commented 5 months ago

But with npm start I am getting the same error. Several restarts later, still the same.

I also created a test file and have started it with pm2. In the test-out.log file there ist 20.11.0

What else can I do?

hermanho commented 5 months ago

Could you please try with this version? https://github.com/hermanho/MMM-GooglePhotos/tree/fix/182

nhweb commented 5 months ago

Hello, now I tried to install the fix version. But now MM stucks in black screen and in the mm-error.log file are the following errors:

[12.01.2024 08:06.46.588] [ERROR] WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: /home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:2
import './fetch-polyfill';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1062:15)
    at Module._compile (node:internal/modules/cjs/loader:1097:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13328)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadModule (/home/pi/MagicMirror/js/app.js:127:19)
[12.01.2024 08:06.46.594] [ERROR] App threw an error during load
[12.01.2024 08:06.46.595] [ERROR] /home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:2
import './fetch-polyfill';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1062:15)
    at Module._compile (node:internal/modules/cjs/loader:1097:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13328)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadModule (/home/pi/MagicMirror/js/app.js:127:19)
[12.01.2024 08:06.46.596] [ERROR] Whoops! There was an uncaught exception...
[12.01.2024 08:06.46.600] [ERROR] /home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:2
import './fetch-polyfill';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1062:15)
    at Module._compile (node:internal/modules/cjs/loader:1097:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13328)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadModule (/home/pi/MagicMirror/js/app.js:127:19)
[12.01.2024 08:06.46.600] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
[12.01.2024 08:06.46.600] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

What else can I do?

nhweb commented 5 months ago

I've seen there were some files changed today, so I reinstalled it. But for now I am getting the following error:

[12.01.2024 08:39.57.806] [ERROR] (node:20065) UnhandledPromiseRejectionWarning: TypeError: Readable.fromWeb is not a function
    at Class.tryToIntitialize (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_helper.js:153:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
(Use `electron --trace-warnings ...` to show where the warning was created)
[12.01.2024 08:39.57.806] [ERROR] (node:20065) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
hermanho commented 5 months ago

Please could you execute the following command in MagicMirror directory to check the version?

npm ls electron
nhweb commented 5 months ago

Yes sure.

pi@pidisplay:~/MagicMirror $ npm ls electron
magicmirror@2.22.0 /home/pi/MagicMirror
`-- electron@22.0.0
hermanho commented 5 months ago

It seems the MagicMirror version is an old version. The latest one v2.26.0 is depended on electron v27. Please update the MagicMirror to the latest version and re-install MMM-GooglePhotos from master branch. It should be fine.

nhweb commented 5 months ago

Ok, thank you, for first step I updated electron, now it works. But yes, MM is noch the latest version. I will update it.

Thanks a lot.