Skip to content
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

Debugger causes alt to crap out when JSON.stringify fails #17

Closed
rocketraman opened this issue Jul 16, 2015 · 5 comments
Closed

Debugger causes alt to crap out when JSON.stringify fails #17

rocketraman opened this issue Jul 16, 2015 · 5 comments

Comments

@rocketraman
Copy link

I have a data structure being passed through the dispatcher that contains circular references (third party library, don't ask). When the chrome debugger is enabled a call to JSON.stringify, the following error is raised and alt fails to dispatch the event:

TypeError: Converting circular structure to JSON

The code in which it fails is:

function registerAlt() {
  ....
  listeners = alts.map(function (obj, i) {
    ....
    var listener = finalStore.listen(function (_ref) {
      ...
      post("DISPATCH", {
        alt: i,
        id: id,
        action: payload.details.id,
        data: JSON.stringify(payload.data)     // <----- fails here
      });

So I think there are two problems:

  1. The Chrome debugger hook should probably just log any failures but allow the dispatch to continue.

  2. The stringify should handle circular refs. See this stack question for a way to do that: http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json

@jareware
Copy link
Contributor

I've hit the same issue once or twice. I'm inclined to agree with 1), because I don't think it's in any way mandatory to get the payload into the devtool. It's NICE of course but no need to halt the app.

@chodorowicz
Copy link

@goatslacker Can you compile the crx with this fix? Or describe a away to create crx from sources?

@jareware
Copy link
Contributor

jareware commented Oct 4, 2015

This would be nice! I've just manually patched this in to the extension source, and then promptly forgot about it. Which means it'll break whenever I reinstall for some reason...

@goatslacker
Copy link
Owner

👍 I'll amend with @jareware's patch

@goatslacker
Copy link
Owner

Patched and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants