Skip to content

Commit

Permalink
Merge pull request #842 from getsentry/release-3.10.0
Browse files Browse the repository at this point in the history
3.10.0
  • Loading branch information
benvinegar authored Jan 30, 2017
2 parents d7e787e + dbe3768 commit 0dd3675
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.10.0

* NEW: Raven.js will exponentially back off if server returns a 400-level error (e.g. 429 too many requests). See: https://github.com/getsentry/raven-js/pull/839
* CHANGE: Raven.js will not set lastEventId if transmission failed because Raven is not configured. See: https://github.com/getsentry/raven-js/pull/839
* BUGFIX: Raven.js now properly handles Firefox resource:// URLs (extensions). See: https://github.com/getsentry/raven-js/pull/837

## 3.9.2
* BUGFIX: Use json-stringify-safe in React Native plugin to avoid circular refs. See: https://github.com/getsentry/raven-js/pull/829
* BUGFIX: Avoid document.location access in React Native plugin. See: https://github.com/getsentry/raven-js/issues/800
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-js",
"version": "3.9.2",
"version": "3.10.0",
"dependencies": {},
"main": "dist/raven.js",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/console.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/console.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/ember.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/ember.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/require.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/require.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/vue.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 76 additions & 7 deletions dist/raven.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.9.2 (5286373) | github.com/getsentry/raven-js */
/*! Raven.js 3.10.0 (d7e787e) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down Expand Up @@ -155,6 +155,7 @@ function Raven() {
this._keypressTimeout;
this._location = _window.location;
this._lastHref = this._location && this._location.href;
this._resetBackoff();

for (var method in this._originalConsole) { // eslint-disable-line guard-for-in
this._originalConsoleMethods[method] = this._originalConsole[method];
Expand All @@ -172,7 +173,7 @@ Raven.prototype = {
// webpack (using a build step causes webpack #1617). Grunt verifies that
// this value matches package.json during build.
// See: https://github.com/getsentry/raven-js/issues/465
VERSION: '3.9.2',
VERSION: '3.10.0',

debug: false,

Expand Down Expand Up @@ -291,6 +292,10 @@ Raven.prototype = {

self._globalEndpoint = self._globalServer +
'/' + path + 'api/' + self._globalProject + '/store/';

// Reset backoff state since we may be pointing at a
// new project/server
this._resetBackoff();
},

/*
Expand Down Expand Up @@ -1414,6 +1419,48 @@ Raven.prototype = {
return httpData;
},

_resetBackoff: function() {
this._backoffDuration = 0;
this._backoffStart = null;
},

_shouldBackoff: function() {
return this._backoffDuration && now() - this._backoffStart < this._backoffDuration;
},

_setBackoffState: function(request) {
// If we are already in a backoff state, don't change anything
if (this._shouldBackoff()) {
return;
}

var status = request.status;

// 400 - project_id doesn't exist or some other fatal
// 401 - invalid/revoked dsn
// 429 - too many requests
if (!(status === 400 || status === 401 || status === 429))
return;

var retry;
try {
// If Retry-After is not in Access-Control-Expose-Headers, most
// browsers will throw an exception trying to access it
retry = request.getResponseHeader('Retry-After');
retry = parseInt(retry, 10);
} catch (e) {
/* eslint no-empty:0 */
}


this._backoffDuration = retry
// If Sentry server returned a Retry-After value, use it
? retry
// Otherwise, double the last backoff duration (starts at 1 sec)
: this._backoffDuration * 2 || 1000;

this._backoffStart = now();
},

_send: function(data) {
var globalOptions = this._globalOptions;
Expand Down Expand Up @@ -1479,6 +1526,13 @@ Raven.prototype = {
return;
}

// Backoff state: Sentry server previously responded w/ an error (e.g. 429 - too many requests),
// so drop requests until "cool-off" period has elapsed.
if (this._shouldBackoff()) {
this._logDebug('warn', 'Raven dropped error due to backoff: ', data);
return;
}

this._sendProcessedPayload(data);
},

Expand All @@ -1490,6 +1544,8 @@ Raven.prototype = {
var self = this;
var globalOptions = this._globalOptions;

if (!this.isSetup()) return;

// Send along an event_id if not explicitly passed.
// This event_id can be used to reference the error within Sentry itself.
// Set lastEventId after we know the error should actually be sent
Expand All @@ -1500,8 +1556,6 @@ Raven.prototype = {

this._logDebug('debug', 'Raven about to send:', data);

if (!this.isSetup()) return;

var auth = {
sentry_version: '7',
sentry_client: 'raven-js/' + this.VERSION,
Expand All @@ -1528,13 +1582,21 @@ Raven.prototype = {
data: data,
options: globalOptions,
onSuccess: function success() {
self._resetBackoff();

self._triggerEvent('success', {
data: data,
src: url
});
callback && callback();
},
onError: function failure(error) {
self._logDebug('error', 'Raven transport failed to send: ', error);

if (error.request) {
self._setBackoffState(error.request);
}

self._triggerEvent('failure', {
data: data,
src: url
Expand Down Expand Up @@ -1562,7 +1624,9 @@ Raven.prototype = {
opts.onSuccess();
}
} else if (opts.onError) {
opts.onError(new Error('Sentry error code: ' + request.status));
var err = new Error('Sentry error code: ' + request.status);
err.request = request;
opts.onError(err);
}
}

Expand Down Expand Up @@ -1937,7 +2001,12 @@ module.exports = Raven;
'use strict';

/*
TraceKit - Cross brower stack traces - github.com/occ/TraceKit
TraceKit - Cross brower stack traces
This was originally forked from github.com/occ/TraceKit, but has since been
largely re-written and is now maintained as part of raven-js. Tests for
this are in test/vendor.
MIT license
*/

Expand Down Expand Up @@ -2317,7 +2386,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
if (typeof ex.stack === 'undefined' || !ex.stack) return;

var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
lines = ex.stack.split('\n'),
stack = [],
Expand Down
4 changes: 2 additions & 2 deletions dist/raven.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/raven.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/sri.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"@dist/raven.js": {
"hashes": {
"sha256": "LJk9mpSaLNe5OiPeVilljWT/19pH0m8BVTv5beKC3iM=",
"sha512": "hjC0XVht94rSQP/cvndw3Z0NB5UsDgojmYAZ5Dk5j44OQGgW4jfVjFjvecNrhPXjec4dtFaFdP9PyCqW/CIX6w=="
"sha256": "Ys1HQR6AleMV2krlqqcgwN3c5N4pmvshjql3Gqh4lAs=",
"sha512": "Bxo/PvUYWXEydrDuy7Rt9tC6b1s345htx2826JIQ6WBrr4WW0aiUDVPJz3G99con//Y58kpqZirX7YfMgKiiZg=="
},
"type": null,
"integrity": "sha256-LJk9mpSaLNe5OiPeVilljWT/19pH0m8BVTv5beKC3iM= sha512-hjC0XVht94rSQP/cvndw3Z0NB5UsDgojmYAZ5Dk5j44OQGgW4jfVjFjvecNrhPXjec4dtFaFdP9PyCqW/CIX6w==",
"integrity": "sha256-Ys1HQR6AleMV2krlqqcgwN3c5N4pmvshjql3Gqh4lAs= sha512-Bxo/PvUYWXEydrDuy7Rt9tC6b1s345htx2826JIQ6WBrr4WW0aiUDVPJz3G99con//Y58kpqZirX7YfMgKiiZg==",
"path": "dist/raven.js"
},
"@dist/raven.min.js": {
"hashes": {
"sha256": "RQ2cvD7tXgOG7hgiNUknpPGVg3Eu7UI5sO4lmb2Mloo=",
"sha512": "FPpKmmpnrw6sYdChKdgzuUeAOHIVtug53GBhmanL57JKgVvU+1kngVPZuTcZU8cwptB0P0cE/ImnmIEgdF1avg=="
"sha256": "FUlyzCCcGC0KyC/Kz5SHya4DjzFZy5Qiqu1Lwn85Rw4=",
"sha512": "Lui8cCX+5QtuqtW38Jhdyn1I04lzqjY7bMJkqSKXTkq0piu1OlQDSRVArtZoiONZYNA2dFoDfZxlMGI/fkJQWQ=="
},
"type": null,
"integrity": "sha256-RQ2cvD7tXgOG7hgiNUknpPGVg3Eu7UI5sO4lmb2Mloo= sha512-FPpKmmpnrw6sYdChKdgzuUeAOHIVtug53GBhmanL57JKgVvU+1kngVPZuTcZU8cwptB0P0cE/ImnmIEgdF1avg==",
"integrity": "sha256-FUlyzCCcGC0KyC/Kz5SHya4DjzFZy5Qiqu1Lwn85Rw4= sha512-Lui8cCX+5QtuqtW38Jhdyn1I04lzqjY7bMJkqSKXTkq0piu1OlQDSRVArtZoiONZYNA2dFoDfZxlMGI/fkJQWQ==",
"path": "dist/raven.min.js"
}
}
2 changes: 1 addition & 1 deletion docs/sentry-doc-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
}
},
"vars": {
"RAVEN_VERSION": "3.9.2"
"RAVEN_VERSION": "3.10.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-js",
"version": "3.9.2",
"version": "3.10.0",
"license": "BSD-2-Clause",
"homepage": "https://github.com/getsentry/raven-js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Raven.prototype = {
// webpack (using a build step causes webpack #1617). Grunt verifies that
// this value matches package.json during build.
// See: https://github.com/getsentry/raven-js/issues/465
VERSION: '3.9.2',
VERSION: '3.10.0',

debug: false,

Expand Down
4 changes: 2 additions & 2 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ describe('globals', function() {
extra: {'session:duration': 100},
});
assert.deepEqual(opts.auth, {
sentry_client: 'raven-js/3.9.2',
sentry_client: 'raven-js/3.10.0',
sentry_key: 'abc',
sentry_version: '7'
});
Expand Down Expand Up @@ -1051,7 +1051,7 @@ describe('globals', function() {
extra: {'session:duration': 100},
});
assert.deepEqual(opts.auth, {
sentry_client: 'raven-js/3.9.2',
sentry_client: 'raven-js/3.10.0',
sentry_key: 'abc',
sentry_secret: 'def',
sentry_version: '7'
Expand Down

0 comments on commit 0dd3675

Please sign in to comment.