Open ezar opened 5 years ago
What is the line immediately before it?
I can't tell if it's an actual error, or it may just be a line break. It is in the function that sends all notifications on the web console to the PM2/terminal console--it may just be a blank notification sent by another module.
Message complete:
1|MagicMir | 2019-03-11T22:21:58
Seems that you need to protect this line (34), if payload is null, no?
It depends on which payload
is causing the issue (there is a payload sent from the logging module which has a nested payload.payload
from the original notification it is echoing--I should have named it differently, but that's another problem).
The parent payload
shouldn't be undefined. I'll have to troubleshoot.
Do you have any errors or messages in the web console (DevTools, ctrl+shift+i)?
Also, confirm there are no 'Module Notification:...' lines nearby the above lines?
Confirm that there are no 'Module Notification:...'
FULL STACK:
1|MagicMir | 2019-03-12T14:01:50
OK. I will troubleshoot when I get a chance. For now you can change line 33 to:
if (notification === "NOTIFICATION_TO_CONSOLE" && payload) {
Thanks! It works ;)
I just installed this, but I'm seeing the same error. Line 33 already matches what you have above.
Here's a section from my log where CALEXT2 is logging...
019-11-07T13:23:50
I had the same error and possibly solved it by changing line 33 to
if (notification === "NOTIFICATION_TO_CONSOLE" && payload.length) {
I THINK the reason is "payload" is a valid object therefore it is true. But its only element is "undefined". This can be solved by asking if payload has a length (a number of defined elements)
I was getting the same error around MMM-Hotword activity. I made lavolp3’s change and it worked for me as well. Thanks!
Revisiting this after several years :-) I need to say I'm not happy with my solution.
The palyoad is actually an opject that is sent from the frontend module notification system and should be properly parsed.
I inserted a console.log(payload)
and got this:
[31.08.2023 17:44.14.833] [LOG] 2023-08-31 17:44:14 <log> {"notification":"REGISTER_VOICE_MODULE","sender":"MMM-soccer"} (/home/pi/MagicMirror/modules/MMM-Logging/node_helper.js:34 Class.socketNotificationReceived)
[31.08.2023 17:44.14.830] [LOG] 2023-08-31 17:44:14 <log> payload: undefined (/home/pi/MagicMirror/modules/MMM-Logging/node_helper.js:35 Class.socketNotificationReceived)
Hence, the payload is there (the object containing the notification), but not properly parsed.
I may have found the solution, and it could be a simple bracket thing. Following seems to work:
if (notification === "NOTIFICATION_TO_CONSOLE" && message) {
tracer.log("Module Notification: " + message.notification + ((message.sender) ? " from " + message.sender : "") + ((message.payload) ? " payload: " + JSON.stringify(message.payload, undefined, 3) : " "));
}
Note the additional brackets I added around the message.payload condition
I was just looking into this, and I changed payload.payload
in line 34 to just payload
, and it seems to give me useful information.
See #6
1|MagicMir | 2019-03-10T19:05:12 payload: undefined (/home/pi/MagicMirror/modules/MMM-Logging/node_helper.js:34 Class.socketNotificationReceived)
Do you know why appears this message?