Skip to content

Commit 83a4d85

Browse files
author
Robert Jackson
authored
Handle module failures gracefully while gathering telemetry. (#125)
Handle module failures gracefully while gathering telemetry.
2 parents cf3077f + 657f8ce commit 83a4d85

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/gather-telemetry.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,29 @@ module.exports = async function gatherTelemetry(url) {
99

1010
// Get the "viewport" of the page, as reported by the page.
1111
const telemetry = await page.evaluate(() => {
12+
const SKIPPED_MODULES = ["fetch/ajax"];
13+
1214
/* globals window, Ember */
1315
let telemetry = {};
1416

1517
const modules = Object.keys(window.require.entries);
1618

1719
for (let modulePath of modules) {
18-
let module = require(modulePath);
20+
if (SKIPPED_MODULES.includes(modulePath)) {
21+
continue;
22+
}
1923

20-
if (module && module.default && module.default.proto) {
21-
let defaultProto = module.default.proto();
24+
try {
25+
let module = require(modulePath);
2226

23-
telemetry[modulePath] = parseMeta(Ember.meta(defaultProto));
27+
if (module && module.default && module.default.proto) {
28+
let defaultProto = module.default.proto();
29+
30+
telemetry[modulePath] = parseMeta(Ember.meta(defaultProto));
31+
}
32+
} catch (error) {
33+
// log the error, but continue
34+
console.error(`error evaluating \`${modulePath}\`: ${error.message}`); // eslint-disable-line no-console
2435
}
2536
}
2637

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
throw new Error('This should not fail the telemetry gathering!');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
throw new Error('This should not fail the telemetry gathering!');

0 commit comments

Comments
 (0)