AlCalzone / node-tradfri-client

Library to talk to IKEA Trådfri Gateways without external binaries
MIT License
264 stars 30 forks source link

The network stack was reset. crashes Node-Red #582

Open LarsSimonsen opened 2 years ago

LarsSimonsen commented 2 years ago

My Node-Red crashes in its entirety every few hours. I'm on Windows 10, Node-Red 2.2.0, node-red-contrib-ikea-home-smart 0.3.3. The last console output entry looks like this:

1 Feb 07:50:34 - [red] Uncaught Exception:
1 Feb 07:50:34 - [error] Error: The network stack was reset. Pending promises will not be fulfilled.
    at TradfriClient.<anonymous> (C:\Users\***\.node-red\node_modules\node-tradfri-client\build\tradfri-client.js:1011:40)
    at Generator.throw (<anonymous>)
    at rejected (C:\Users\***\.node-red\node_modules\node-tradfri-client\build\tradfri-client.js:6:65)

Should I catch it with an exception node? I'm puzzled that it brings Node-Red down completely, did't know that a single node had the power to do that.

AlCalzone commented 2 years ago

The error comes from here: https://github.com/AlCalzone/node-tradfri-client/blob/9bf1929eea3fd161b83a4bb843174123754aef71/src/tradfri-client.ts#L1222-L1251

It could be that the node doesn't have an event handler for the "error" event attached, which Node.js might treat as a unhandled exception. IMO, this event should be listened for and reacted accordingly by the application/node/... which wraps node-tradfri-client. It might be fine to just swallow this error, but some commands won't be fulfilled as the error message says. So it's really up to the caller to decide how to handle this.

If this happens every few hours, this seems like there's something weird going on. Are you often using the app in parallel to this library, which could force a reconnection?

LarsSimonsen commented 2 years ago

I don't use the app often, but my SO might. OTOH, this seems to happen when automations adjust many lights in a short time.

So should I take this issue to node-red-contrib-ikea-home-smart instead?

AlCalzone commented 2 years ago

So should I take this issue to node-red-contrib-ikea-home-smart instead?

Yeah, I guess that needs to be handled there. In this specific case, node-tradfri-client can't do much else than tell the application what happened.