Skip to content

Commit a912ddf

Browse files
mattrobenoltbenvinegar
authored andcommitted
Add json-stringify-safe to avoid circular JSON references (#652)
1 parent 4a8591b commit a912ddf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"url": "git://github.com/getsentry/raven-js.git"
1414
},
1515
"main": "src/singleton.js",
16+
"dependencies": {
17+
"json-stringify-safe": "^5.0.1"
18+
},
1619
"devDependencies": {
1720
"browserify-versionify": "^1.0.6",
1821
"bundle-collapser": "^1.2.1",

src/raven.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
var TraceKit = require('../vendor/TraceKit/tracekit');
55
var RavenConfigError = require('./configError');
66
var utils = require('./utils');
7+
var stringify = require('json-stringify-safe');
78

89
var isFunction = utils.isFunction;
910
var isUndefined = utils.isUndefined;
@@ -428,7 +429,7 @@ Raven.prototype = {
428429
*/
429430
getContext: function() {
430431
// lol javascript
431-
return JSON.parse(JSON.stringify(this._globalContext));
432+
return JSON.parse(stringify(this._globalContext));
432433
},
433434

434435

@@ -1314,7 +1315,7 @@ Raven.prototype = {
13141315
// NOTE: auth is intentionally sent as part of query string (NOT as custom
13151316
// HTTP header) so as to avoid preflight CORS requests
13161317
request.open('POST', url + '?' + urlencode(opts.auth));
1317-
request.send(JSON.stringify(opts.data));
1318+
request.send(stringify(opts.data));
13181319
},
13191320

13201321
_logDebug: function(level) {

0 commit comments

Comments
 (0)