sentry-javascript: TypeError: Converting circular structure to JSON (error object includes circular references)

Package + Version

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

Version:

4.4.2

Description

Error:

TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at Object.serialize (/srv/node_modules/@sentry/utils/object.js:17:17)
    at /srv/node_modules/@sentry/node/dist/transports/base.js:66:42
    at new Promise (<anonymous>)
    at HTTPSTransport.<anonymous> (/srv/node_modules/@sentry/node/dist/transports/base.js:40:39)
    at step (/srv/node_modules/tslib/tslib.js:133:27)
    at Object.next (/srv/node_modules/tslib/tslib.js:114:57)
    at /srv/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/srv/node_modules/tslib/tslib.js:103:16)
    at HTTPSTransport.BaseTransport.sendWithModule (/srv/node_modules/@sentry/node/dist/transports/base.js:36:24)
    at HTTPSTransport.<anonymous> (/srv/node_modules/@sentry/node/dist/transports/https.js:32:44)
    at step (/srv/node_modules/tslib/tslib.js:133:27)
    at Object.next (/srv/node_modules/tslib/tslib.js:114:57)
    at /srv/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)

This is how we are capturing the errors:

withScope((scope) => {
  scope.setTag('maintenance_task_execution_id', maintenanceTaskExecutionId);
  scope.setTag('maintenance_task_id', maintenanceTaskId);
  scope.setTag('maintenance_task_nid', maintenanceTaskNid);

  captureException(error);
});

All tag values are primitive.

error might include circular references, e.g. reference to HTTP request object.

Appears to be related to:

https://github.com/getsentry/sentry-javascript/issues/651

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 12
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@klaascuvelier thanks for the solution with version 4.4.1

I have a similar issue with @sentry/browser@4.4.2. Getting the circular structure error on 2 places:

  • when I do a console.log of my message, disabling the console in the Breadcrumbs Integration fixed this
  • when captureException is called.

Downgrading to 4.4.1 fixes both of the issues

Wanted to add a stackblitz example but can’t get sentry/browser@4.4.2 working on there. 4.4.1 does work for me: https://sentry-circular-issue.stackblitz.io

PR with a fix is coming. Will release tomorrow morning as we want to get some more patches in. Sorry for the inconvenience. I was pretty sure that safely storing users data will be enough to prevent circular refs. Apparently not :<

@HazAT Sorry for being so unprecise. had been very much work these days. We used it on a video streaming website. When the videoplayer (videojs) raised an error the script came in an infinite loop whilst removing the circular structures. videojs is a very huge object with a lot of circulars and unpredictible errors 😕 . It is hard to reproduce, but i will try in the next days.

That’s great! Thanks! 🥳

@mhemrg downgrading to 4.4.1 fixed for me