Skip to content

Commit

Permalink
Do not extend backoff reporting useless errors (ampproject#6565)
Browse files Browse the repository at this point in the history
These include already reported errors (which somehow got thrown again),
cancelled loading messages, and now a large majority of loading errors.

If we had a whole bunch of loading errors, and then a real honest to god
bug, we'd almost never receive the bug because the "reported" loading
errors would delay sending the message for so long.
  • Loading branch information
jridgewell authored and Vanessa Pasque committed Dec 22, 2016
1 parent bcb3978 commit 77f90ac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ self.AMPErrors = accumulatedErrorMessages;
* @param {function()} work the function to execute after backoff
* @return {number} the setTimeout id
*/
let globalExponentialBackoff = function(work) {
// Set globalExponentialBackoff as the lazy-created function. JS Vooodoooo.
globalExponentialBackoff = exponentialBackoff(1.5);
return globalExponentialBackoff(work);
let reportingBackoff = function(work) {
// Set reportingBackoff as the lazy-created function. JS Vooodoooo.
reportingBackoff = exponentialBackoff(1.5);
return reportingBackoff(work);
};

/**
Expand Down Expand Up @@ -187,11 +187,11 @@ function reportErrorToServer(message, filename, line, col, error) {
}
const url = getErrorReportUrl(message, filename, line, col, error,
hasNonAmpJs);
globalExponentialBackoff(() => {
if (url) {
if (url) {
reportingBackoff(() => {
new Image().src = url;
}
});
});
}
}

/**
Expand Down

0 comments on commit 77f90ac

Please sign in to comment.