Check whether the request url is null or not to avoid error. (#1146)

Summary:
### The existing issue
[The `buildRow` function in `network/index.js`](c7ff6f6266/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
This commit is contained in:
Zheng Rongyan
2020-05-11 07:15:15 -07:00
committed by Facebook GitHub Bot
parent 3ddfdcbff1
commit 2dcb73aba5

View File

@@ -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');