question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON Serialization error with circular reference

See original GitHub issue

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.4.3,5.5.0

Description

When serializing an event/error that contains a circular reference, a browser error occurs, and then that error is logged, losing the original error.

Repro steps: open a console with sentry SDK loaded and initialized, run:

var obj = {};
obj.repro = obj;
Sentry.captureEvent(obj);

Logged stack trace in Sentry from the above:

TypeError
Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    --- property 'repro' closes the circle
<anonymous> in JSON.stringify
../src/transports/fetch.ts in sendEvent at line 15:18
../../core/src/basebackend.ts in sendEvent at line 96:21
../../core/src/baseclient.ts in onfulfilled at line 353:32
../../utils/src/syncpromise.ts in onSuccess at line 127:21
../../utils/src/syncpromise.ts at line 86:52
<anonymous> in Array.forEach
../../utils/src/syncpromise.ts in _executeHandlers at line 86:22
../../utils/src/syncpromise.ts in _attachHandler at line 96:10
../../utils/src/syncpromise.ts in callback at line 106:12
../../utils/src/syncpromise.ts in new n at line 42:7
../../utils/src/syncpromise.ts in then at line 105:12
../../core/src/baseclient.ts in callback at line 342:46
../../utils/src/syncpromise.ts in new n at line 42:7
../../core/src/baseclient.ts in _processEvent at line 341:12
../../core/src/baseclient.ts in method at line 135:10
../../hub/src/hub.ts in _invokeClient at line 81:27
../../hub/src/hub.ts in method at line 223:10
../../minimal/src/index.ts in callOnHub at line 13:17
../../minimal/src/index.ts in Object.n.captureEvent at line 64:10
<anonymous> at line 3:8

Link to affected production issue in Sentry (my guess is that this is an error involving the Datatables JS library, not sure though): https://sentry.io/organizations/grasp-and-grow/issues/1107636848/

I see similar issues, but they seem to involve memory consumption and crashes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
cgeorgcommented, Aug 12, 2019

We’re using the ASP.NET bundling for that, it looks like it doesn’t support source mapping out of the box. I’m trying to put together a codepen but can’t get it to trigger the same issue. Having trouble getting around CORS things with codepen to hit the exact code path - I will update if I can get a simple repro for you.

1reaction
kamilogorekcommented, Nov 7, 2019

We already do this for Events, but it requires onerror data to be in place. Here we’d have to assume that a message can be either string or this event object, which is non-standard in any format. This would simply require too much additional boilerplate to handle, and it’s the first time I see such behaviour in the wild.

It won’t be the most beautiful error report you’ll ever see, but when paired with $.fn.dataTable.ext.errMode = 'throw'; you’ll get necessary information. See: https://datatables.net/manual/tech-notes/7

Patched here: https://github.com/getsentry/sentry-javascript/pull/2302

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix Circular Reference Error When Dealing With Json
A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo '. Description: An unhandled exception ...
Read more >
JsonSerializer support for circular references #30496 - GitHub
Object/collection graphs containing circular references (or multiple references to the same entity), can be handled in a few different ways ...
Read more >
How to get around the Circular Reference issue with JSON ...
My Issue comes into play with serializing my Model objects into JSON. I am using the code first method to create my database....
Read more >
Avoiding Circular Reference for Entity in JSON Serialization
The circular reference issue might happen also in WCF script services or in other places while serializing Entity Framework's entities into JSON ......
Read more >
Circular references in JSONSerializer and StackOverflow ...
Circular references causes StackOverflow Exceptions the same as calling a never ending recursive function which crashes all Apps. The solution ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found