node.getEndpoint call fails sometimes
See original GitHub issueThis appears to be a race condition as it only manifests itself sometimes.
When you call node.getEndpoint, it will throw an exception at some occasions. In the WS server we call this right after “value added” to determine the CC version of the CC belonging to the value. 99% of the times this is OK but sometimes this fails, I believe this happens when interview is still busy ?
Code in the WS server where the exception throws: https://github.com/zwave-js/zwave-js-server/blob/master/src/lib/forward.ts#L142
Capture of the error:
10:52:59.106 DRIVER Node 28, Endpoint undefined: Trying to access endpoint instance before Multi Channel interview
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot read property 'getCCVersion' of undefined
at ZWaveNode.<anonymous> (/usr/lib/node_modules/@zwave-js/server/dist/lib/forward.js:107:56)
at ZWaveNode.emit (events.js:315:20)
at ZWaveNode.EventEmitter.emit (domain.js:467:12)
at ZWaveNode.translateValueEvent (/usr/lib/node_modules/@zwave-js/server/node_modules/zwave-js/src/lib/node/Node.ts:346:8)
at ValueDB.emit (events.js:315:20)
at ValueDB.EventEmitter.emit (domain.js:467:12)
at ValueDB.setValue (/usr/lib/node_modules/@zwave-js/server/node_modules/@zwave-js/core/src/values/ValueDB.ts:224:10)
at new ConfigurationCCReport (/usr/lib/node_modules/@zwave-js/server/node_modules/zwave-js/src/lib/commandclass/ConfigurationCC.ts:916:22)
at new CommandClass (/usr/lib/node_modules/@zwave-js/server/node_modules/zwave-js/src/lib/commandclass/CommandClass.ts:108:13)
at new ConfigurationCC (/usr/lib/node_modules/@zwave-js/server/node_modules/zwave-js/src/lib/commandclass/ConfigurationCC.ts:484:3)
I can simply wrap the call in a try…except or first check if the endpoint is defined but that doesn’t really fix the issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
node.js - Express router GET endpoint gives Not Found error
My request. GET http://localhost:3000/dev/v1/abc/48/def. I'm having an issue with the first GET endpoint not reaching and getting 404 ...
Read more >Understanding Axios GET requests - LogRocket Blog
Learn how to make GET requests in Axios with query parameters and API keys, plus concurrent and HEAD requests and error handling.
Read more >Fetch API – How to Make a GET Request and POST Request ...
As a result, you will not be able to use it in a Node.js environment (unless you install a special module). How to...
Read more >Cassandra troubleshooting guide - Site24x7
If only a particular query consistently fails, you can use nodetool getendpoints to get all the nodes that own a particular partition key....
Read more >Building requests | Postman Learning Center
To test the https://postman-echo.com/get endpoint, leave the GET method selected and select Send. The same location (sometimes called ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for all the help and insight again. We’re going the safer route and only request all these metadata after the node is ready.
Yeah, the problem here is that the node is sending a multi channel encapsulated command (from an endpoint), which zwave-js emits as a value event, so it doesn’t get missed.
However at that point the
Multi Channel CC
interview was not completed yet, sozwave-js
does not have any information about endpoints yet. You’re trying to read the CC version of that endpoint which is also not known yet at that point, since the endpoint interview happens after theMulti Channel CC
interview of the node.Long story short: The type declarations reflect the error too.
Workaround (I assume your TS version is high enough to support optional chaining):
getEndpoint(0)
is also a no-op, it just returns the node instance itself.I’m not sure how you use these versions, but keep in mind that falling back to the node version in this case can leave you with outdated information after the interview is completed.