Don't invalidate connection files on Network Errors

Summary:
On iOS devices (internal only right now), when flipper desktop isn't running we get a Network Error instead of a Port not open error, because we can always connect to the port forwarding server running on the phone.
So in this case, don't count this error as a failure so we don't needlessly delete the certificates to attempt to fix it.

Reviewed By: passy

Differential Revision: D13358147

fbshipit-source-id: 8f9fb62cd2dcada058d104ef60f788a1b62d7094
This commit is contained in:
John Knox
2018-12-06 06:51:29 -08:00
committed by Facebook Github Bot
parent ee23119f24
commit dc313a460c

View File

@@ -128,10 +128,16 @@ void FlipperConnectionManagerImpl::startSync() {
}
step->complete();
} catch (const folly::AsyncSocketException& e) {
if (e.getType() == folly::AsyncSocketException::NOT_OPEN) {
if (e.getType() == folly::AsyncSocketException::NOT_OPEN ||
e.getType() == folly::AsyncSocketException::NETWORK_ERROR) {
// The expected code path when flipper desktop is not running.
// Don't count as a failed attempt.
step->fail("Port not open");
// Don't count as a failed attempt, or it would invalidate the connection
// files for no reason. On iOS devices, we can always connect to the local
// port forwarding server even when it can't connect to flipper. In that
// case we get a Network error instead of a Port not open error, so we
// treat them the same.
step->fail(
"No route to flipper found. Is flipper desktop running? Retrying...");
} else {
log(e.what());
failedConnectionAttempts_++;