From 308d63fe938e473b6eba2cc7668f5834d96078fd Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 31 May 2019 17:01:42 -0700 Subject: [PATCH] console.log shouldn't throw warning if metro isn't running Summary: When metro is not running, D15559151 caused infinite exceptions (fetch threw an error if it couldn't connect to localhost:8081) which affected UI. Swallow those errors and everything works well, with or without metro. Reviewed By: yungsters Differential Revision: D15588623 fbshipit-source-id: d170ea82478545836a7a22a228196c9778e93ef0 --- Libraries/Core/Devtools/logToConsole.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/Core/Devtools/logToConsole.js b/Libraries/Core/Devtools/logToConsole.js index ecad232cb9..93806e76cb 100644 --- a/Libraries/Core/Devtools/logToConsole.js +++ b/Libraries/Core/Devtools/logToConsole.js @@ -27,6 +27,13 @@ function logToConsole( fetch(getDevServer().url + 'log-to-console', { method: 'POST', body, + }).catch(e => { + // ...Oh well! + // If metro is running, logs should be sent to metro. + // If metro is NOT running, this will throw an exception every time... and + // those exceptions will be caught and logged, which will throw another + // exception, etc, causing infinite exception loop which affects UI perf. + // If we swallow silently here, that won't happen. }); }