-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Converting circular structure to JSON #2809
Comments
We have thousand of errors like this with
and
and
Why not stringify in a try catch block? |
I'm also seeing this error multiple times a day and it's making it difficult to keep track of legitimate issues. If anyone has advice on how to filter these out , that would be greatly appreciated! |
This is the only error getting reported for me whenever legitimate exceptions are triggered. |
Sorry you all are having trouble! I have a few questions:
Also, it would be great if one of you could post a link to an example of such an error in Sentry. We (theoretically) eliminate any cycles before we get to the jsonifying step. |
Hi @lobsterkatie,
Yes. I am using 6.7.1 and last received a new TypeError JSON.stringify() 2 hours ago.
Yes, I can reproduce the error by submitting a particular form within my application... No errors are generated in the browser console.
Does this help?
Thanks for looking into this! Tim |
Thanks. Yes, I saw that stacktrace in the original post, and it makes sense that that's where the problem is happening. And sorry for being unclear, but I was actually hoping that since you can reproduce it, you could stick a debugger in your code right before the crash and look at the |
I don't really know anything about Sentry so I don't think I'm going to be much help with debugging this. However I can send you a screen recording and username / password to our SAAS where you can investigate further. I'll post those details in the support ticket I opened with Sentry. |
We've been running into this error lately, and the bad part is, it supercedes the actual error we're trying to capture. So users are running into bugs in our app, and we can't get the full context. Here's a link to such an issue (only Sentry support will be able to access it): Public link for everyone else: In our case, we're passing a Vue component's entire Vue.prototype.$reportError = function (
exception: any,
options: ReportErrorOptions,
metadata?: Record<string, any>
) {
reportError(exception, options, {
...metadata,
component: this.$options.name,
componentProps: JSON.parse(safeJsonStringify(this.$props)),
componentData: JSON.parse(safeJsonStringify(this.$data)),
});
} I'll try this going forward, though ideally, Sentry should probably perform a safe stringify internally to save us the step. 🙂 |
I did more debugging on why we're seeing this issue and it's related to usage of the cookies package. I believe the |
We do that for |
@kamilogorek So, to continue showing that path from the code above: The object in the 3rd argument above gets passed into export default function reportError(
exception: any,
options: ReportErrorOptions,
metadata?: Record<string, any>
) {
let extra = metadata || {}; and then: Sentry.setContext('clientData', {
...extra,
rawException: exception,
while: options.while,
}); So, indeed, it's the context that's not being safe-stringified, it looks like. |
That is really odd, as we definitely normalize those, see: https://github.com/getsentry/sentry-javascript/blob/master/packages/core/src/baseclient.ts#L331-L393 🤔 |
Though, the error is happening in a Hmm, so maybe it's not the context. |
That's an accurate assessment, however, |
Let us know if there's some way we can help pinpoint the issue! |
What I did to debug #3727 is:
Once we have the source, we'll be able to reproduce and patch it easily. The biggest problem now is actually knowing the source of that reference. |
I'll try that out next time I get some free time, unless someone beats me to it! |
I can't seem to replicate it now, but our users in production sure can. 😕 The last error was interesting, actually. The error was properly caught (it was an S3 timeout error): But it also generated a separate "circular structure" issue, too. There must've been something in the S3 error that it didn't like, just not sure what. I'm fairly certain it wasn't anything I was setting in the context or extra. |
The above fix worked for me. That said, I've attached the json stacktrace from Sentry. Does this help you track down the root cause? |
Unfortunately, there's nothing that'd point to the malformed data in this JSON log. |
If someone stumbles upon this issue, starting Sentry.init({
_experiments: {
ensureNoCircularStructures: true
}
}) This should allow the malformed events to be delivered to Sentry and should allow you to see some |
@Ben-Mack - Can you please link to the above issues in Sentry? |
Downgrading to 7.1.1 fixed it for me. |
Hello, we also have this problem on 7.3.0. event id: 14578f51f61045039d61d7de5f6830a7 by looking into stack trace, it looks like problem is somewhere around here: https://github.com/getsentry/sentry-javascript/blob/master/packages/utils/src/envelope.ts#L71 |
@lforst sure thing, here you are: https://sentry.io/organizations/schizofreny/issues/3369770918/events/ed99a33af0b14e39bfdc2287da2f43e1/?project=5278129 However as I am looking at the event, it actually stopped - no idea why. |
Issued on applying
|
Can we re-open this issue? This is not fixed, I can't upgrade until we get a resolution, and it appears that many people are in the same situation. |
@xmunoz yeah. We need to find a way to fix this sustainably. Currently, we only normalize parts of the payload we send to Sentry and it seems like "unsafe"/circular data slips through in some places. It's a bit like playing Whac-A-Mole. I have a solution in mind where we normalize events in one central place right before sending it to Sentry, however, this involves rethinking how data is passed to the SDK and handled within (i.e. somehow marking all data that is given to the SDK or gathered by the SDK as "unsafe"). |
This is still an issue for us, and we're using
|
The thing I'm most concerned about is if this is an actual error that Sentry is attempting to log or if it's just a random Sentry error we can ignore. Hopefully not the former, which means we're missing potentially important issues. https://sentry.io/share/issue/2e7b97a984c14c3496eada587f42efc2/ @lforst @kamilogorek @lobsterkatie Any insight into this? |
This is still an issue for us, using
Would it make sense to use something like https://www.npmjs.com/package/json-stable-stringify instead of |
@ffxsam Generally, when this error happens, the SDK is trying to log something. 😕 I'd currently be interested in how many people are affected by this and to what extent/event count so we can prioritize this. Nevertheless, I'm gonna bug the rest of the team about this error some more because I am a bit tired of looking at this particular issue. 😄 |
If it helps at all, I'm using the Vue integration. I'll bet that it's passing part of a Vue component into Sentry and that might be causing the issue. |
We've seen 28 of these in the last 14 days in our nodejs project, would love a fix! |
@alexblack 28 different issues or a total event count of 28? Still trying to get a feeling for how pressing this is. |
28 events of this error (typeerror converting...)
I believe in each case Sentry failed to record the actual error that
occurred, since it threw an exception while processing an error
…On Thu, Aug 11, 2022, 11:59 PM Luca Forstner ***@***.***> wrote:
We've seen 28 of these in the last 14 days in our nodejs project, would
love a fix!
@alexblack <https://github.com/alexblack> 28 different issues or a total
event count of 28? Still trying to get a feeling for how pressing this is.
—
Reply to this email directly, view it on GitHub
<#2809 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABELQUIG7BW23RJF7ZQVNDVYXY3TANCNFSM4P4ON5BQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Any chance of a fix? Would some simple defensive programming help? eg catch this much closer to the source (and report it to your own sentry, instead of ours), then continue to report the actual error to our sentry (missing whatever failed |
I haven't been able to upgrade past 7.1.1 because of this bug. |
Ok small update here: I just merged #5851 which is supposed to get rid of the circular reference error in case a circular reference error would occur. It's probably not bulletproof yet and also has a slight performance penalty - which is why this hopefully won't be a permanent solution. We still hope this will fix the issue. It will be included in the next release of the SDK. I'll respond to this issue again once it's released to let everybody know. |
This fix has been released with https://github.com/getsentry/sentry-javascript/releases/tag/7.14.1, please let us know if there are any issues! |
I am currently seeing this issue (I think, at least it looks similar), I'm using the nextjs sdk, version 7.102.0. I'd assume that version has the fix you deployed? Happy to provide any details if it will help. Seeing this in Sentry:
And I only seem to get this error from mobile devices. If there's any more information I can provide, or if you want me to open a new ticket or anything, just let me know. Thanks! |
@mihoward21 This should not happen at all anymore. Are you sure this is coming from the SDK and not some other part of your application? What does the stack trace show? |
@lforst I'm not sure of anything, lol. Been trying to figure this out for a while and am quite perplexed. I'm adding breadcrumbs before my own calls to Sentry's Here is a stack trace from chrome mobile on an android: And here is another stack trace from mobile safari on iphone: |
Could this just be an issue with a browser extension (or something similar specific to mobile devices)? That's my best guess right now |
@mihoward21 So this does not look like the error is coming from inside the SDK. Otherwise we'd see Sentry SDK code as the top frame. It's most likely some other code running on your page - what exactly we cannot say. It might very well be a browser extension. |
Package + Version
@sentry/browser
5.19.1Version:
Description
Error:
This is how we're reporting exceptions:
The text was updated successfully, but these errors were encountered: