timoschlueter/nightscout-librelink-up

Crash when fetching last entry from Nightscout "TypeError: resp.data.pop is not a function"

Opened this issue · 0 comments

aleb commented

The Client.lastEntry() method in src/nightscout/apiv1.ts fails to handle the response from the Nightscout server.

A workaround is to specify ALL_DATA: "true" which would not call lastEntry but get insted all entries.

Not 100% sure when this happens. Maybe when the mongodb used by Nightscout is down, or when Nightscout did not receive entries in a long time.

Using the latest "latest" docker image:

$ docker pull timoschlueter/nightscout-librelink-up
Using default tag: latest
latest: Pulling from timoschlueter/nightscout-librelink-up
Digest: sha256:76e96bc901577a32a801eb3f31e491e1a074bab556345f244419148fee0bd2cc
Status: Image is up to date for timoschlueter/nightscout-librelink-up:latest
docker.io/timoschlueter/nightscout-librelink-up:latest
$ docker compose logs nightscout-librelinkup  -f
nightscout-librelinkup  | 
nightscout-librelinkup  | > nightscout-librelink-up@2.7.0 start-heroku
nightscout-librelinkup  | > node dist/index.js
nightscout-librelinkup  | 
nightscout-librelinkup  | [info]: Starting cron schedule: */1 * * * *
nightscout-librelinkup  | [info]: renew token
nightscout-librelinkup  | [info]: Logged in to LibreLink Up
nightscout-librelinkup  | [debug]: authenticatedHttpHeaders: {"User-Agent":"Mozilla/5.0 (iPhone; CPU OS 17_4.1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/17.4.1 Mobile/10A5355d Safari/8536.25","Content-Type":"application/json;charset=UTF-8","version":"4.10.0","product":"llu.ios","Authorization":"..."}
nightscout-librelinkup  | [info]: Found 1 LibreLink Up connection.
nightscout-librelinkup  | [info]: -> The following connection will be used: XXX (Patient-ID: XXX)
nightscout-librelinkup  | [debug]: authenticatedHttpHeaders: {"User-Agent":"Mozilla/5.0 (iPhone; CPU OS 17_4.1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/17.4.1 Mobile/10A5355d Safari/8536.25","Content-Type":"application/json;charset=UTF-8","version":"4.10.0","product":"llu.ios","Authorization":"XXX"}
nightscout-librelinkup  | /usr/src/app/dist/nightscout/apiv1.js:30
nightscout-librelinkup  |         return resp.data.pop();
nightscout-librelinkup  |                          ^
nightscout-librelinkup  | 
nightscout-librelinkup  | TypeError: resp.data.pop is not a function
nightscout-librelinkup  |     at Client.lastEntry (/usr/src/app/dist/nightscout/apiv1.js:30:26)
nightscout-librelinkup  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
nightscout-librelinkup  |     at async createFormattedMeasurements (/usr/src/app/dist/index.js:236:47)
nightscout-librelinkup  |     at async uploadToNightScout (/usr/src/app/dist/index.js:257:35)
nightscout-librelinkup  |     at async main (/usr/src/app/dist/index.js:129:5)
nightscout-librelinkup  | 
nightscout-librelinkup  | Node.js v20.15.0
nightscout-librelinkup exited with code 1