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

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

Open
LarsSimonsen opened this issue Feb 1, 2022 · 3 comments
Open

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

LarsSimonsen opened this issue Feb 1, 2022 · 3 comments

Comments

@LarsSimonsen
Copy link

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
Copy link
Owner

AlCalzone commented Feb 1, 2022

The error comes from here:

private swallowInternalCoapRejections<T>(promise: Promise<T>): Promise<T> {
// We use the conventional promise pattern here so we can opt to never
// resolve the promise in case we want to redirect it into an emitted error event
return new Promise(async (resolve, reject) => {
try {
// try to resolve the promise normally
resolve(await promise);
} catch (e) {
if (/coap\s?client was reset/i.test(e.message)) {
// The CoAP client was reset. This happens when the user
// resets the CoAP client while connections or requests
// are still pending. It's not an error per se, so just
// inform the user about what happened.
this.emit("error", new TradfriError(
"The network stack was reset. Pending promises will not be fulfilled.",
TradfriErrorCodes.NetworkReset,
));
} else if (/dtls handshake timed out/i.test(e.message)) {
// The DTLS layer did not complete a handshake in time.
this.emit("error", new TradfriError(
"Could not establish a secure connection in time. Pending promises will not be fulfilled.",
TradfriErrorCodes.ConnectionTimedOut,
));
} else {
reject(e);
}
}
});
}

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
Copy link
Author

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
Copy link
Owner

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.

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

No branches or pull requests

2 participants