From f743940d0282a04d40b32357ed24d694f9f7cb62 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 13 Aug 2020 07:57:54 -0700 Subject: [PATCH] [network[ Fix missing response status code bug Summary: There's a bug in the network inspector. Messages come in in batches for performance reasons. These batches can include both requests and responses, but the code assumes only one or the other. This fixes it to make it not mutually exclusive. This bug only affects row building in the table, so when you click on the row, you can still see the response and everything. Reviewed By: cekkaewnumchai Differential Revision: D23102575 fbshipit-source-id: 47e8c6b0f1c9cf0d5860b6f349a7d9fe225c73ae --- desktop/plugins/network/index.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/desktop/plugins/network/index.tsx b/desktop/plugins/network/index.tsx index d575ca5d9..0c7ad1e2a 100644 --- a/desktop/plugins/network/index.tsx +++ b/desktop/plugins/network/index.tsx @@ -694,20 +694,25 @@ function calculateState( } } } - } else if (props.responses !== nextProps.responses) { + } + if (props.responses !== nextProps.responses) { // new or updated response - const resId = Object.keys(nextProps.responses).find( + const resIds = Object.keys(nextProps.responses).filter( (responseId: RequestId) => props.responses[responseId] !== nextProps.responses[responseId], ); - if (resId) { - const request = nextProps.requests[resId]; - // sanity check; to pass null check - if (request) { - const newRow = buildRow(request, nextProps.responses[resId]); - const index = rows.findIndex((r: TableBodyRow) => r.key === request.id); - if (index > -1 && newRow) { - rows[index] = newRow; + for (const resId of resIds) { + if (resId) { + const request = nextProps.requests[resId]; + // sanity check; to pass null check + if (request) { + const newRow = buildRow(request, nextProps.responses[resId]); + const index = rows.findIndex( + (r: TableBodyRow) => r.key === request.id, + ); + if (index > -1 && newRow) { + rows[index] = newRow; + } } } }