Open TheCranston opened 2 years ago
@rickkas7 Good morning. The uncaught exception restart of nodered is happening several times a day. Is there a deeper debug trace I can capture that will help? I wouldn't have known this is happening if I did have an event notification push to my phone on state change in the flow. Anyway, please let me know best how to proceed. thanks!
More findings. So it appears that the issue is around the re-authentication timeout. I found
res.body.expires_in: 7776000
which works out to be about 2 hours in ms. The same amount of time between faults and restarts. I over rode the value and set it to the max and it's been "holding" just fine. That's a work around and the core issue of a fault in the re-auth code persists. I'm not a javascript coder so I'm outta my depth on how to fix it or I'd have submitted a PR. Any and all help is appreciated. thanks!
Additional testing outside of homeasistant on a plain desktop install of node-red yielded the same results. However I was able to scope it down to the function nodes. the subscribe nodes do not exhibit this issue causing node-red to throw an uncaught exception. the desktop was running node-red v2.1.5 with node.js v17.3.0 on x64 linux
I have the same problem when a migrate to v3 so I revert to 2.2.2 and is working again (node.js 16). I also tried another node from other author "node-red-contrib-particle", without success (similar problem?). Probably changed authentication particle's answer and newer versions are more unstable to the change.
@FranGarVal That has been my workaround as well. However it's not a long term option. Given https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=nodejs I'd like to keep reasonably updated to mitigate security issues.
I installed in Raspberry Pi (Node v18.7.0) and exactly same problem :frowning:
Reauthenticating... Authenticated with Particle 20 Aug 15:21:23 - [red] Uncaught Exception: 20 Aug 15:21:23 - [error] TypeError: Cannot destructure property 'onEvent' of 'undefined' as it is undefined. at Api.listenToEventStream (/home/fran/.node-red/node_modules/@particle/node-red-contrib-particle-official/src/api.js:53:24) at login.then.retryIn (/home/fran/.node-red/node_modules/@particle/node-red-contrib-particle-official/src/api.js:169:29) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'.
I've fixed this in a fork. Until it is merged in, you can install direct with
npm install git+https://github.com/sberkovitz/node-red-contrib-particle-official.git
More findings. So it appears that the issue is around the re-authentication timeout. I found
res.body.expires_in: 7776000
which works out to be about 2 hours in ms. The same amount of time between faults and restarts. I over rode the value and set it to the max and it's been "holding" just fine. That's a work around and the core issue of a fault in the re-auth code persists. I'm not a javascript coder so I'm outta my depth on how to fix it or I'd have submitted a PR. Any and all help is appreciated. thanks!
How did you override this setting?
@mjscoiot in api.js I simply used the max value rather than lower of max and the expires_in value received. nasty hack. I'm not a java programmer for certain. A far better approach is what @sberkovitz did in his fork. I'd consider that the correct path as it actually addresses the exception. Let's hope that his PR is accepted.
I ended up just commenting out everthing in the _reauthenticate function
after .login
such that basically it doesn't retry the login within that
section of code in
@.***/node-red-contrib-particle-official/src/api.js`.
Seems to work flawlessly since login rarely fails.
On Sat, Dec 23, 2023 at 7:21 AM TheCranston @.***> wrote:
@mjscoiot https://github.com/mjscoiot in api.js I simply used the max value rather than lower of max and the expires_in value received. nasty hack. I'm not a java programmer for certain. A far better approach is what @sberkovitz https://github.com/sberkovitz did in his fork. I'd consider that the correct path as it actually addresses the exception. Let's hope that his PR is accepted.
— Reply to this email directly, view it on GitHub https://github.com/particle-iot/node-red-contrib-particle-official/issues/3#issuecomment-1868293714, or unsubscribe https://github.com/notifications/unsubscribe-auth/BE3367HLOBIAIRAWNLSRH33YK3LEBAVCNFSM5L4LWV7KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBWHAZDSMZXGE2A . You are receiving this because you were mentioned.Message ID: <particle-iot/node-red-contrib-particle-official/issues/3/1868293714@ github.com>
I've had the particle integration via node-red working for quite a while now and at some point a guess a version change happened and now every so many hours I get this cycle of "Reauthenticating" then "exception" and finally node red restarts.
Not quite sure what's happening. Below is the log of one of these events.