Skip to content

Commit ad70ef7

Browse files
committed
Add logging for transport failure + suppressed error
1 parent f55cd08 commit ad70ef7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/raven.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,8 +1328,9 @@ Raven.prototype = {
13281328

13291329
_setBackoffState: function(request) {
13301330
// if we are already in a backoff state, don't change anything
1331-
if (this._shouldBackoff())
1331+
if (this._shouldBackoff()) {
13321332
return;
1333+
}
13331334

13341335
var status = request.status;
13351336

@@ -1357,10 +1358,6 @@ Raven.prototype = {
13571358
},
13581359

13591360
_send: function(data) {
1360-
if (this._shouldBackoff()) {
1361-
return;
1362-
}
1363-
13641361
var globalOptions = this._globalOptions;
13651362

13661363
var baseData = {
@@ -1424,6 +1421,13 @@ Raven.prototype = {
14241421
return;
14251422
}
14261423

1424+
// Backoff state: Sentry server previously responded w/ an error (e.g. 429 - too many requests),
1425+
// so drop requests until "cool-off" period has elapsed.
1426+
if (this._shouldBackoff()) {
1427+
this._logDebug('warn', 'Raven dropped error due to backoff: ', data);
1428+
return;
1429+
}
1430+
14271431
this._sendProcessedPayload(data);
14281432
},
14291433

@@ -1483,6 +1487,8 @@ Raven.prototype = {
14831487
callback && callback();
14841488
},
14851489
onError: function failure(error) {
1490+
self._logDebug('error', 'Raven transport failed to send: ', error);
1491+
14861492
if (error.request) {
14871493
self._setBackoffState(error.request);
14881494
}

0 commit comments

Comments
 (0)