timoschlueter / nightscout-librelink-up

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.
MIT License
192 stars 246 forks source link

Cannot read properties of undefined (reading 'dateString') #40

Closed convay89 closed 2 years ago

convay89 commented 2 years ago

Hi,

after setting up Nightscout via Heroku (successfully). I tried to set up libre link up, also via Heroku. But unfortunatily I receive always the following error.

2022-05-01T18:20:00.514429+00:00 app[worker.1]: [info]: no authTicket.expires 2022-05-01T18:20:00.514465+00:00 app[worker.1]: [info]: renew token 2022-05-01T18:20:01.164961+00:00 app[worker.1]: [info]: Logged in to LibreLink Up 2022-05-01T18:20:01.672330+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection. 2022-05-01T18:20:01.672344+00:00 app[worker.1]: [info]: -> The following connection will be used: XXXXXX (Patient-ID: ) 2022-05-01T18:20:02.254026+00:00 app[worker.1]: [info]: Received blood glucose measurement items 2022-05-01T18:20:02.394919+00:00 app[worker.1]: [error]: Error getting glucose measurements Cannot read properties of undefined (reading 'dateString')

timoschlueter commented 2 years ago

hi @convay89, I will take a look at this. Thanks for pointing it out.

1spammer commented 2 years ago

Same error here, i think i'm Missing Something. Did a fresh Nightscout Setup via heroku. Nightscout is up and running. Are there some Variables I forgot to set in Nightscout?

2022-05-02T19:37:33.144318+00:00 app[worker.1]: [info]: Starting cron schedule: /1 * 2022-05-02T19:38:00.463465+00:00 app[worker.1]: [info]: Logged in to LibreLink Up 2022-05-02T19:38:00.684776+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection. 2022-05-02T19:38:00.685117+00:00 app[worker.1]: [info]: -> The following connection will be used: xxxxx (Patient-ID: xxxx-xxx-xxxx-xxxx-xxxx) 2022-05-02T19:38:00.189910+00:00 app[worker.1]: [info]: no authTicket.expires 2022-05-02T19:38:00.190143+00:00 app[worker.1]: [info]: renew token 2022-05-02T19:38:01.100264+00:00 app[worker.1]: [info]: Received blood glucose measurement items 2022-05-02T19:38:01.167682+00:00 app[worker.1]: [error]: Error getting glucose measurements Cannot read properties of undefined (reading 'dateString')

blooolb commented 2 years ago

The Problem is the empty Nightscout API response on new installations. The code expects at least a single returned entry to determine the timestamp the last entry. The code is missing a simple check whether any results were returned before trying to access them in line index.js#L188

return new Date(response.data.pop().dateString);

timoschlueter commented 2 years ago

This should be fixed in version 1.6.2 :)