diff --git a/core/gather/gatherers/dobetterweb/response-compression.js b/core/gather/gatherers/dobetterweb/response-compression.js index 50ce6f637f27..64673822b526 100644 --- a/core/gather/gatherers/dobetterweb/response-compression.js +++ b/core/gather/gatherers/dobetterweb/response-compression.js @@ -13,9 +13,10 @@ import {Buffer} from 'buffer'; import {gzip} from 'zlib'; +import log from 'lighthouse-logger'; + import BaseGatherer from '../../base-gatherer.js'; import UrlUtils from '../../../lib/url-utils.js'; -import {Sentry} from '../../../lib/sentry.js'; import {NetworkRequest} from '../../../lib/network-request.js'; import DevtoolsLog from '../devtools-log.js'; import {fetchResponseBodyFromCache} from '../../driver/network.js'; @@ -119,12 +120,13 @@ class ResponseCompression extends BaseGatherer { }); }); }).catch(err => { - Sentry.captureException(err, { - tags: {gatherer: 'ResponseCompression'}, - extra: {url: UrlUtils.elideDataURI(record.url)}, - level: 'warning', - }); + const isExpectedError = err?.message?.includes('No resource with given identifier found'); + if (!isExpectedError) { + err.extra = {url: UrlUtils.elideDataURI(record.url)}; + throw err; + } + log.error('ResponseCompression', err.message); record.gzipSize = undefined; return record; }); diff --git a/core/test/gather/gatherers/dobetterweb/response-compression-test.js b/core/test/gather/gatherers/dobetterweb/response-compression-test.js index 24bfb08b25aa..0e2684a8cc43 100644 --- a/core/test/gather/gatherers/dobetterweb/response-compression-test.js +++ b/core/test/gather/gatherers/dobetterweb/response-compression-test.js @@ -145,14 +145,21 @@ describe('Optimized responses', () => { expect(artifact[0].gzipSize).toEqual(26); }); - it('recovers from driver errors', async () => { - mocks.networkMock.fetchResponseBodyFromCache.mockRejectedValue(new Error('Failed')); + it('recovers from cache ejection errors', async () => { + mocks.networkMock.fetchResponseBodyFromCache.mockRejectedValue( + new Error('No resource with given identifier found')); const artifact = await gatherer.getCompressibleRecords(context, networkRecords); expect(artifact).toHaveLength(2); expect(artifact[0].resourceSize).toEqual(6); expect(artifact[0].gzipSize).toBeUndefined(); }); + it('does not suppress other errors', async () => { + mocks.networkMock.fetchResponseBodyFromCache.mockRejectedValue(new Error('Failed')); + await expect(gatherer.getCompressibleRecords(context, networkRecords)) + .rejects.toThrow(); + }); + it('ignores responses from installed Chrome extensions', async () => { const networkRecords = [ {