Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixing Libre Linkup Crash #34

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

billyjbryant
Copy link

Description

When the connect plugin pulls data for Libre LinkUp, if last_known is null, the plugin crashes with the following error, causing a reboot loop on the container:

 /opt/app/node_modules/nightscout-connect/lib/sources/librelinkup.js:124
       var last_updated = last_known.entries;
                                     ^

 TypeError: Cannot read properties of null (reading 'entries')
     at Object.transformGlucose [as transformer] (/opt/app/node_modules/nightscout-connect/lib/sources/librelinkup.js:124:37)
     at transformService (/opt/app/node_modules/nightscout-connect/lib/machines/fetch.js:14:37)
     at Interpreter._exec (/opt/app/node_modules/xstate/lib/interpreter.js:269:63)
     at Interpreter.exec (/opt/app/node_modules/xstate/lib/interpreter.js:1026:10)
     at Interpreter.execute (/opt/app/node_modules/xstate/lib/interpreter.js:387:14)
     at Interpreter.update (/opt/app/node_modules/xstate/lib/interpreter.js:415:12)
     at /opt/app/node_modules/xstate/lib/interpreter.js:110:15
     at Scheduler.process (/opt/app/node_modules/xstate/lib/scheduler.js:69:7)
     at Scheduler.schedule (/opt/app/node_modules/xstate/lib/scheduler.js:48:10)
     at Interpreter.send (/opt/app/node_modules/xstate/lib/interpreter.js:104:23)

This is fixed by adding in appropriate checks to ensure that direct reference to an undefined var are not performed and thus prevents the system from crashing.

fixes: #27

@billyjbryant
Copy link
Author

Is anyone going to review this? It has been in for 6 weeks with no review or comment.

@billyjbryant billyjbryant changed the title [FIX] Fixing Libre Linkup Crash fix: Fixing Libre Linkup Crash Feb 29, 2024
@AndyLow91
Copy link
Contributor

AndyLow91 commented Mar 1, 2024

Definitely safe to merge this, the var last_updated doesn't appear to be used at all throughout the rest of the script. In any case adding the ternary operator makes perfect sense.

This line may not even be needed, or it may for some future plans.

Just to be safe, I have also tested with this updated and confirmed working, although I couldn't recreate the problem locally either way, i can see that this could cause the problem stated.

@bewest approval is required to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LibreLinkUp crashes when last_known is null
2 participants