When making requests, if the unifi controller is offline or otherwise unreachable the requests would never time out.
This could cause an application to get stuck waiting for the request promise to resolve which will never happen, or if the application performs its own timeouts will leak the memory of the in-flight request.
The 5s value has been chosen arbitrarily, as something that feels sensible for something on a local network.
Additionally, I inlined the _connect function, as it was called in one place and the checking of the return value resulted in some dead code
When making requests, if the unifi controller is offline or otherwise unreachable the requests would never time out. This could cause an application to get stuck waiting for the request promise to resolve which will never happen, or if the application performs its own timeouts will leak the memory of the in-flight request.
The 5s value has been chosen arbitrarily, as something that feels sensible for something on a local network.
Additionally, I inlined the
_connect
function, as it was called in one place and the checking of the return value resulted in some dead code