MMM-Assistant icon indicating copy to clipboard operation
MMM-Assistant copied to clipboard

Error in GA authentication

Open E3V3A opened this issue 6 years ago • 5 comments

When running the google-auth.sh script, it spits out an error before you have a chance to enter anything. However, it still runs and gives the token you need.

$ node google-auth.js

Attempted to automatically open the URL, but if it failed, copy/paste this in your browser:
<url shown here>
Paste your code: 
(node:3869) UnhandledPromiseRejectionWarning: Error: Exited with code 3
    at ChildProcess.cp.once.code (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/opn/index.js:84:13)
    at Object.onceWrapper (events.js:272:13)
    at ChildProcess.emit (events.js:180:13)
    at maybeClose (internal/child_process.js:936:16)
    at Socket.stream.socket.on (internal/child_process.js:353:11)
    at Socket.emit (events.js:180:13)
    at Pipe._handle.close [as _onclose] (net.js:538:12)

(node:3869) 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(). (rejection id: 1)

(node:3869) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. 
In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

<pasted-code-here>
Google Authentication is finished. Press Ctrl+C for quit.
^C

It seem to be a problem in the opn library, so I filed an issue there.

E3V3A avatar Mar 17 '18 09:03 E3V3A

That is not errors, just warnings for deprecating futures. Anyway I wish I get a time or interests for fixing it. :(

eouia avatar Mar 20 '18 10:03 eouia

@eouia The first message is an error: (node:3869) UnhandledPromiseRejectionWarning: Error: Exited with code 3, meaning that even the rejection warning errored out!

E3V3A avatar Mar 21 '18 06:03 E3V3A

@E3V3A It maybe because of unhandled promise in this file: MMM-Assistant/node_modules/google-assistant/components/auth.js Line 47

opn(url)

As you see opn(url) returns a promise but has not been handled. Hence the warning. Can you please replace this line with the one below and try it out?

opn(url).catch((error) => {});

Let me know

dev-z avatar Apr 20 '18 11:04 dev-z

@dev-z Hi! Thank you so much for trying to help. Unfortunately I have broken my RPi from a shitty Kernel update, so I need fix that first before I can run the test. BTW. You also posted this:

opn(uri).then((res) => {
    console.info(res);
}, (err) => {
    console.error(err);
});

What would be the difference?

E3V3A avatar Apr 22 '18 16:04 E3V3A

@E3V3A The difference is that in case of

opn(url).catch((error) => {});

I am just concerned about the error handling. I do not handle the success scenario; whereas, in case of

opn(uri).then((res) => {
    console.info(res);
}, (err) => {
    console.error(err);
});

I am logging the success response as well as the error. Use the former if you are not concerned about the success scenario.

dev-z avatar Apr 23 '18 04:04 dev-z