From 2dcb73aba5075be7b1ee3554e7ea9e26fc04e6d6 Mon Sep 17 00:00:00 2001 From: Zheng Rongyan Date: Mon, 11 May 2020 07:15:15 -0700 Subject: [PATCH] Check whether the request url is null or not to avoid error. (#1146) Summary: ### The existing issue [The `buildRow` function in `network/index.js`](https://github.com/facebook/flipper/blob/c7ff6f6266c712ca6152d4038f8b960914282ddb/desktop/plugins/network/index.tsx#L458) doesn't check if the url is valid. However, since the `request` data comes from the App which developers are building, there will be an error, if the `request.url` is `null` or `undefined`. ![image](https://user-images.githubusercontent.com/7471672/81561808-5c536b80-93c6-11ea-846b-3aa76d726350.png) When this error occurs, the `NetworkTable` can't go back to normal even I try to click `Clear error and try again`. Only after killing the Flipper desktop and restart again, it can work again. ![error](https://user-images.githubusercontent.com/7471672/81563438-d553c280-93c8-11ea-86be-883fa457dda3.gif) ### How to fix In order to make `Flipper` desktop more stable, I think it is better to check the url is valid and avoid the crash. ## Changelog - check the url in the `buildRow` function in `network/index.js` Pull Request resolved: https://github.com/facebook/flipper/pull/1146 Test Plan: - [x] Using the same input `request` data, `Flipper` will not show this row and it works as normal. ![image](https://user-images.githubusercontent.com/7471672/81562713-e819c780-93c7-11ea-809d-cf6893c58a68.png) Reviewed By: jknoxville Differential Revision: D21502032 Pulled By: passy fbshipit-source-id: 1dd8ad7f13297ce99680053447024a8563b8a975 --- desktop/plugins/network/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop/plugins/network/index.tsx b/desktop/plugins/network/index.tsx index b71b347a3..311c6b5de 100644 --- a/desktop/plugins/network/index.tsx +++ b/desktop/plugins/network/index.tsx @@ -455,6 +455,10 @@ function buildRow( if (request == null) { return null; } + + if (request.url == null) { + return null; + } const url = new URL(request.url); const domain = url.host + url.pathname; const friendlyName = getHeaderValue(request.headers, 'X-FB-Friendly-Name');