티스토리 수익 글 보기

티스토리 수익 글 보기

Add error handling for URL metric compression · WordPress/performance@6c8c257 · GitHub
Skip to content

Commit 6c8c257

Browse files
b1ink0westonruter
andcommitted
Add error handling for URL metric compression
Co-authored-by: Weston Ruter <westonruter@google.com>
1 parent 1d78aaf commit 6c8c257

File tree

1 file changed

+10
1
lines changed

1 file changed

+10
1
lines changed

plugins/optimization-detective/detect.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,16 @@ function debouncedCompressUrlMetric() {
409409
} );
410410
idleCallbackHandle = null;
411411
}
412-
compressedPayload = await compress( JSON.stringify( urlMetric ) );
412+
try {
413+
compressedPayload = await compress( JSON.stringify( urlMetric ) );
414+
} catch ( err ) {
415+
const { error } = createLogger( false, consoleLogPrefix );
416+
error(
417+
'Failed to compress URL Metric falling back to sending uncompressed data:',
418+
err
419+
);
420+
compressionEnabled = false;
421+
}
413422
recompressionTimeout = null;
414423
}, 1000 );
415424
}

0 commit comments

Comments
 (0)