Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(fonts): fix infinite loop #4488

Merged
merged 2 commits into from
Feb 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lighthouse-core/gather/gatherers/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const Gatherer = require('./gatherer');
const Sentry = require('../../lib/sentry');
const fontFaceDescriptors = [
'display',
'family',
Expand Down Expand Up @@ -119,7 +120,7 @@ function getFontFaceFromStylesheets() {
promises.push(Promise.resolve(getSheetsFontFaces(stylesheet)));
}
} catch (err) {
promises.push(loadStylesheetWithCORS(stylesheet.ownerNode));
promises.push({err: {message: err.message, stack: err.stack}});
}
}
// Flatten results
Expand All @@ -145,11 +146,18 @@ class Fonts extends Gatherer {
]
).then(([loadedFonts, fontFaces]) => {
return loadedFonts.map(fontFace => {
if (fontFace.err) {
const err = new Error(fontFace.err.message);
err.stack = fontFace.err.stack;
Sentry.captureException(err, {tags: {gatherer: 'Fonts'}, level: 'warning'});
return null;
}

const fontFaceItem = this._findSameFontFamily(fontFace, fontFaces);
fontFace.src = (fontFaceItem && fontFaceItem.src) || [];

return fontFace;
});
}).filter(Boolean);
});
}
}
Expand Down