From fa00575dec6bc2ee2d82cfdb7ff876aa20dee3f8 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Mon, 7 Dec 2020 09:43:42 -0800 Subject: [PATCH] Fix `unexpected end of JSON` error Summary: This is the 6th most common error in our logging, and I just run into it after upgrading XCode. It happens when idb doesn't return any devices. (because `''.split('\n')` results in `['']` not `[]`) Reviewed By: jknoxville Differential Revision: D25368759 fbshipit-source-id: 44b0e3a5dc4cf06ecdf2dff4a5692943e60d4b1d --- desktop/app/src/utils/iOSContainerUtility.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/app/src/utils/iOSContainerUtility.tsx b/desktop/app/src/utils/iOSContainerUtility.tsx index a8c6f0500..ede7d6720 100644 --- a/desktop/app/src/utils/iOSContainerUtility.tsx +++ b/desktop/app/src/utils/iOSContainerUtility.tsx @@ -70,6 +70,7 @@ async function targets(idbPath: string): Promise> { .trim() .split('\n') .map((line) => line.trim()) + .filter(Boolean) .map((line) => JSON.parse(line)) .filter(({type}: IdbTarget) => type !== 'simulator') .map((target: IdbTarget) => { @@ -83,6 +84,7 @@ async function targets(idbPath: string): Promise> { .toString() .split('\n') .map((line) => line.trim()) + .filter(Boolean) .map((line) => /(.+) \([^(]+\) \[(.*)\]( \(Simulator\))?/.exec(line)) .filter(notNull) .filter(([_match, _name, _udid, isSim]) => !isSim)