disqus-react: Uncaught TypeError: Converting circular structure to JSON

Describe the bug

When using the DiscussionEmbed component this error is generated:

Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ReactCompositeComponentWrapper'
    |     property '_instance' -> object with constructor 'App'
    --- property '_reactInternalInstance' closes the circle
    at JSON.stringify (<anonymous>)
    at b.Channel.h.sendMessage (embed.js:44)
    at e.<anonymous> (embed.js:45)
    at e.<anonymous> (embed.js:44)
    at e.<anonymous> (embed.js:44)
    at m (embed.js:44)
    at e.trigger (embed.js:44)
    at e.<anonymous> (embed.js:44)
    at m (embed.js:44)
    at b.Channel.trigger (embed.js:44)

It appears that embed.js is trying to stringify the config to use sendMessage, which includes a reference to the DIV container for the discussion, but that includes react references in it which are circular.

To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo
  2. npm i && npm run build:example && npm start
  3. Navigate to examples, go to an article with a discussion
  4. See error in console

Expected behavior

No error

Specifications:

I assume it’d happen on a few platforms but mine specifically are:

  • OS: MacOS 10.15.7
  • Package version: latest
  • Node version: 12
  • Browser: Chrome 87

Additional context

Not sure if it’s an issue with this package or disqus’s embed.js no longer playing nice with react, either way it needs to be solved by disqus.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Most upvoted comments

The fix just went out, so I would expect that you should stop seeing these issues once the caches clear. I’m going to leave this issue open for the next couple of days to make sure the problem doesn’t persist for anyone and then I’ll close it out.

I’ve made the team aware of this issue and we’re going to try to track down the cause ASAP.