Open burnedikt opened 1 year ago
Actually, I also get this issue when there are entries on nightscout already. I'm having a hard time to pin this down due to the "machines" architecture, but I guess this means the DetermineGaps
step doesn't determine any gap.
Solution is probably just a different check à la
- var last_mills = Math.max(two_days_ago, last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
+ var last_mills = Math.max(two_days_ago, last_known && last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
But it seems odd that last_known
stays null since it should always return something here? https://github.com/nightscout/nightscout-connect/blob/8f2ab374a288f8541b916d92cecfb55bb5f44889/lib/machines/fetch.js#L25.
Logs leading up until the NPE btw:
nightscout | GAP FOR
nightscout | WAITING FOR data-processed
nightscout | ALARM SOCKET: emitted clear_alarm to all clients
nightscout | tick 2023-07-11T08:33:01.117Z
nightscout | DEBUG nightscout-connect {
nightscout | now: 2023-07-11T08:33:01.117Z,
nightscout | type: 'heartbeat',
nightscout | sig: 'internal://heartbeat/1',
nightscout | beat: 1,
nightscout | interval: 60000,
nightscout | started: 2023-07-11T08:32:01.115Z
nightscout | }
nightscout | Load Complete:
nightscout | profiles:1
nightscout | data loaded: reloading sandbox data and updating plugins
nightscout | EVENTUALLY FOUND null
nightscout | /opt/app/node_modules/nightscout-connect/lib/sources/glooko/index.js:85
nightscout | var last_mills = Math.max(two_days_ago, last_known.entries ? last_known.entries.getTime( ) : two_days_ago);
Yes, I think Sulka has some patches that help with this. last_known.entries
and friends should be a date object or may be null. Apologies for this!
Glooko patches from Sulka have been integrated and released. Hope this helps!
Will check, thanks 🙏
Seems like this still happens with the latest version (0.10.0) of nightscout-connect:
EVENTUALLY FOUND null
(node:39418) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'entries' of null
at Object.dataFromSesssion (/cgm-remote-monitor/node_modules/nightscout-connect/lib/sources/glooko/index.js:85:58)
at dataFetchService (/cgm-remote-monitor/node_modules/nightscout-connect/lib/machines/fetch.js:8:19)
at Interpreter._exec (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:269:63)
at Interpreter.exec (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:1026:10)
at Interpreter.execute (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:387:14)
at Interpreter.update (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:415:12)
at /cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:110:15
at Scheduler.process (/cgm-remote-monitor/node_modules/xstate/lib/scheduler.js:69:7)
at Scheduler.schedule (/cgm-remote-monitor/node_modules/xstate/lib/scheduler.js:48:10)
at Interpreter.send (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:104:23)
at _a.id (/cgm-remote-monitor/node_modules/xstate/lib/interpreter.js:1139:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
The following code throws an error if running the connect plugin with glooko credentials on an empty nightscout instance, I assume because there is no
last_known
yet.https://github.com/nightscout/nightscout-connect/blob/8f2ab374a288f8541b916d92cecfb55bb5f44889/lib/sources/glooko/index.js#L85C22-L85C22