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

Running stringify() a second time after an error produces a strange result #11

Open
atduskgreg opened this issue Dec 19, 2015 · 2 comments

Comments

@atduskgreg
Copy link

r = new Resurrect()
var O = {test : function(){console.log("cats")}}
r.stringify(O)
// => Uncaught ResurrectError {message: "Can't serialize functions."...
r.stringify(O)
// => "[]"

I'm just starting out with the library and came across this behavior while playing with it in the console. It's hard (at least at this point) for me to imagine why I'd end up calling this twice on the same object in real code, but this struck me as strange behavior.

@skeeto
Copy link
Owner

skeeto commented Dec 20, 2015

Oops, that's definitely a bug. The problem is that Resurrect is leaving
its marker on the object. When there's an exception, it doesn't clean up
after itself, so next time around it sees the marker, assumes the object
has already been seen, and skips it, hence the empty array in the
result. The cleanup should moved into a finally block so that it happens
regardless.

@atduskgreg
Copy link
Author

That totally makes sense. Thanks for responding so quickly.

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

2 participants