Skip to content

Commit b8f67f2

Browse files
committed
Add json-stringify-safe to avoid circular JSON references
1 parent d781478 commit b8f67f2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@
4949
"sentry",
5050
"raven"
5151
],
52-
"typings": "typescript/raven.d.ts"
52+
"typings": "typescript/raven.d.ts",
53+
"dependencies": {
54+
"json-stringify-safe": "^5.0.1"
55+
}
5356
}

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
/*
@@ -1285,7 +1286,7 @@ Raven.prototype = {
12851286
// NOTE: auth is intentionally sent as part of query string (NOT as custom
12861287
// HTTP header) so as to avoid preflight CORS requests
12871288
request.open('POST', url + '?' + urlencode(opts.auth));
1288-
request.send(JSON.stringify(opts.data));
1289+
request.send(stringify(opts.data));
12891290
},
12901291

12911292
// Note: this is shitty, but I can't figure out how to get

0 commit comments

Comments
 (0)