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

RangeError: Maximum call stack size exceeded #8

Open
benbuckman opened this issue Jul 31, 2013 · 9 comments
Open

RangeError: Maximum call stack size exceeded #8

benbuckman opened this issue Jul 31, 2013 · 9 comments
Assignees

Comments

@benbuckman
Copy link

This breaks with any Backbone view (I assume an example of a common type of object). For example, with backbone, in Chrome, in the console:

safeStringify = require('safe-json-stringify')
m = new Backbone.Model
v = new Backbone.View({ model: m })
safeStringify(v)

Throws an error, "RangeError: Maximum call stack size exceeded"

With the model (m), interestingly, it doesn't throw an error, but it writes an empty object, "{}".

Is this supposed to work only on simple objects, not instances of pseudo-classes?

Thanks

@benbuckman
Copy link
Author

I think it's returning a stringified empty object for the model in that case, because the model's attributes are empty, and it's using toJSON to retrieve the attributes. (I didn't realize JSON.stringify checks toJSON, good to know.) The view error is still a problem, anyway.

Thanks

@benbuckman
Copy link
Author

This also fails with a jquery element:

safeStringify = require('safe-json-stringify')
$ = require('jquery')
safeStringify( $('<div>') )

Throws a

TypeError: Accessing selectionDirection on an input element that cannot have a selection.

Normal JSON.stringify throws a

TypeError: Converting circular structure to JSON

(but I was hoping this module would mitigate that situation)

@davedx
Copy link

davedx commented Jun 13, 2014

I also had a max call stack crash on a DOM event I was trying to stringify. My browser tab actually froze up from it. Maybe it should limit recursion somehow?

@moll
Copy link
Owner

moll commented Mar 3, 2015

Oh, right, toJSON should probably be called as well and before the circular detection.
I'll get to it, too!

@moll moll self-assigned this Mar 3, 2015
@macdja38
Copy link

+1 This module is used within raven's sentry and this has become an issue on a project I'm working on.

@moll
Copy link
Owner

moll commented Feb 23, 2017

ACK. ;)

@joshiefishbein
Copy link

Similar to jQuery, this issue is occurring when used with Cheerio. Crashing the browser when stringifying Cheerio objects.

@zakhenry
Copy link

This issue still exists, in my case causing an infinite loop until the browser runs out of resources. Trying to serialize an thrown exception in an Angular application

@ilog2000
Copy link

ilog2000 commented Feb 2, 2021

This issue causes an error in bunyan logger. The whole app crashes and being recycled.

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

7 participants