Skip to content

Commit d5a6b1c

Browse files
committed
Don't show compression perf for non-decodeable bodies
1 parent 33d7b90 commit d5a6b1c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/components/view/http/http-performance-card.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ const CompressionDescription = observer((p: {
100100
}) => {
101101
const { encodings, encodedBodyLength, decodedBodyLength } = p;
102102

103-
const compressionRatio = decodedBodyLength ? Math.round(100 * (
104-
1 - (encodedBodyLength / decodedBodyLength)
105-
)) : undefined;
103+
const compressionRatio = decodedBodyLength
104+
? Math.round(100 * (1 - (encodedBodyLength / decodedBodyLength)))
105+
: undefined;
106106

107107
return <>
108108
{ encodings.length ? <>
109109
compressed with <strong>{joinAnd(encodings, ', ', ' and then ')}</strong>,
110110
making it {
111-
compressionRatio !== undefined && decodedBodyLength ? <>
111+
compressionRatio !== undefined && decodedBodyLength
112+
? <>
112113
<strong>
113114
{ compressionRatio >= 0 ?
114115
`${compressionRatio}% smaller`
@@ -120,7 +121,8 @@ const CompressionDescription = observer((p: {
120121
} to {
121122
getReadableSize(encodedBodyLength)
122123
})
123-
</> : <Icon icon={['fas', 'spinner']} spin />
124+
</>
125+
: <Icon icon={['fas', 'spinner']} spin />
124126
}
125127
</> :
126128
<strong>not compressed</strong>
@@ -213,10 +215,15 @@ const CompressionPerformance = observer((p: { exchange: HttpExchange }) => {
213215

214216
return <>{ messageTypes.map((messageType) => {
215217
const message = p.exchange[messageType];
216-
const encodings = getEncodings(message);
217218

218-
if (typeof message !== 'object' || !message.body.encodedByteLength) return null;
219+
if (
220+
typeof message !== 'object' ||
221+
!message?.body ||
222+
!message.body.encodedByteLength ||
223+
message.body.isFailed()
224+
) return null;
219225

226+
const encodings = getEncodings(message);
220227
const encodedBodySize = message.body.encodedByteLength;
221228
const decodedBody = message.body.decodedData;
222229
const decodedBodySize = decodedBody ? decodedBody.byteLength : 0;

0 commit comments

Comments
 (0)