nightscout / cgm-remote-monitor

nightscout web monitor
GNU Affero General Public License v3.0
2.36k stars 71.43k forks source link

Cannot upload treatments from xDrip+ after upgrading to v15 #8120

Closed IndrekHaav closed 9 months ago

IndrekHaav commented 9 months ago

Describe the bug After upgrading Nightscout to v15.0.0, treatments entered in xDrip+ no longer appear in Nightscout. The following error shows up in system logs:

Oct 20 07:32:32 nightscout node[15154]: TypeError: api(...).save is not a function
Oct 20 07:32:32 nightscout node[15154]:     at Function.save (/opt/nightscout/lib/server/treatments.js:163:11)
Oct 20 07:32:32 nightscout node[15154]:     at /opt/nightscout/lib/api/treatments/index.js:196:22
Oct 20 07:32:32 nightscout node[15154]:     at Layer.handle [as handle_request] (/opt/nightscout/node_modules/express/lib/router/layer.js:95:5)
Oct 20 07:32:32 nightscout node[15154]:     at next (/opt/nightscout/node_modules/express/lib/router/route.js:137:13)
Oct 20 07:32:32 nightscout node[15154]:     at check (/opt/nightscout/lib/authorization/index.js:268:9)
Oct 20 07:32:32 nightscout node[15154]:     at runMicrotasks (<anonymous>)
Oct 20 07:32:32 nightscout node[15154]:     at processTicksAndRejections (node:internal/process/task_queues:96:5)

Other data like BG readings get uploaded without issue.

To Reproduce Steps to reproduce the behavior:

  1. Enter new treatment in xDrip+
  2. Wait for it to show up in Nightscout
  3. Observe that it does not show up

Expected behavior Treatments are uploaded to Nightscout and visible in the web UI as in previous versions.

Your setup information

WesSec commented 9 months ago

Rollback to 14.2.6 seemed to work for me without any issues/loss of data. After the rollback i did a backfill (under advanced settings in the nightscout settings in xdrip+)

sulkaharo commented 9 months ago

How are you hosting Nightscout? Curious if you made a full redeploy of the dependencies.

WesSec commented 9 months ago

I'm selfhosting via the docker container, so currently on nightscout/cgm-remote-monitor:14.2.6 . My mongo uses the :latest tag and i did not change anything there.

sulkaharo commented 9 months ago

Right. You need to figure out how to update the node dependencies inside the container. That error basically implies the Mongo driver Nightscout is trying to load doesn't match the expected version.

IndrekHaav commented 9 months ago

How are you hosting Nightscout? Curious if you made a full redeploy of the dependencies.

I have Nightscout running in a Debian 12 LXC container. I also updated Node.js to v16, MongoDB is at v4.4. I did run npm install after pulling the v15.0.0 code from Github.

Edit: just to be safe, I nuked the node_modules directory and re-ran npm install. Still the same error when uploading treatments.

bewest commented 9 months ago

Duplicate? https://github.com/nightscout/cgm-remote-monitor/issues/8114

IndrekHaav commented 9 months ago

Not sure. I did update to v15.0.1 but that didn't solve my issue. Editing profiles seemed to work, but I didn't try it on v15.0.0 before updating.

bewest commented 9 months ago

To investigate potential issues, I've deleted package-lock.json and node_modules/ and issued npm install. The difference in package-lock doesn't indicate any differences in the mongo dependency chain. Not sure what the issue is here, but I'm confident we removed the troublesome patches from 15.0.0 in 15.0.1, and it should behave identical to the dev branch before the merge of #8026. I recently tested on node 14, 16, and 18.

IndrekHaav commented 9 months ago

I may have spoken too soon. Some treatments did show up after I manually sent older data from xDrip+ (as @WesSec mentioned in their first comment), perhaps I just didn't wait long enough.

I'll see how it behaves during normal use.

IndrekHaav commented 9 months ago

Okay, looks like it's working with v15.0.1 after all. Sorry for the confusion.

thedewi commented 3 months ago

This is still an issue because: