From dc313a460c6f09bfc177fc333546b275727d8af0 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 6 Dec 2018 06:51:29 -0800 Subject: [PATCH] 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 --- xplat/Flipper/FlipperConnectionManagerImpl.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.cpp b/xplat/Flipper/FlipperConnectionManagerImpl.cpp index 94a8d1d7d..75c51e654 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.cpp +++ b/xplat/Flipper/FlipperConnectionManagerImpl.cpp @@ -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_++;