-
Notifications
You must be signed in to change notification settings - Fork 421
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
Maximum Call Stack Exceeded When Destroying a nested model #476
Conversation
This seems to be an issue with the can.Observe attributes serialize method conflicting with can.Observe.List's serialize method. When attributes get serialized, they're checked against a stack of already serialized observes to prevent infinite loops, but can.Observe.List.prototype.serialize seems to bypass this. |
Wouldn't this just be solvable by using the same stack? |
Yeah, I think this could be easily fixed simply by having can/observe/attributes also override can.Observe.List.prototype.serialize in addition to can.Observe.prototype.serialize. I don't have time at the moment to take care of this but I'll fix it soon. |
I guess I can give it a shot, too if I have time. |
Odd, now I'm not getting an error in the Fiddles. Could possibly be related with the fact that I forgot to update the release folder with 1.1.7 and only did it a week or two ago. Or am I missing something @thecountofzero? |
@daffl, Which fiddle? When I use the following fiddle: http://jsfiddle.net/thecountofzero/a2b3S/ And then enter v.destroy() in the console I get the "RangeError: Maximum call stack size exceeded" |
It's reproducible with this fiddle: http://jsfiddle.net/a2b3S/5/ |
Are you saying doing something like this in attributes.js ? can.Observe.prototype.serialize = can.Observe.List.prototype.serialize = function(attrName, stack) { |
If I enter "can.Observe.List.prototype.serialize = can.Observe.prototype.serialize" in the console of the fiddle, it no longer throws the error. |
I just tried that, too and it seems to work: http://jsfiddle.net/a2b3S/6/ |
Yeah, that should fix it, but like you mentioned, need to verify that it destroys properly as well as serializes lists properly. |
Anyway someone can reduce this to something I can add as a test? |
Try typing "v.attr()" in the console. This will generate the maximum callstack error even with the above proposed fix |
Is this fixed in 2.0.0-pre? |
Closing this. Please reopen if it is still happening in the current release (2.0.2). |
This issue has resurfaced in 2.0.3 (or earlier). Help me Obi-bitovi... |
This should be re-opened |
@thecountofzero if you can reduce those fiddles into something testable by Monday of next week, I'll fix it. Thanks! |
See my comments on the forum. I reduced it a bit, but not much. Globals are needed for associations (attributes plugin) and the rest is the bare minimum to exhibit the issue. |
@justinbmeyer here is a reduced fiddle. |
I'm digging this one too, and in the meanwhile I found out something at least interesting. I'm not sure as to how this adds for the discussion, but anyway, If one deferred FOO is resolved after another BAR, FOO just gets serialized and BAR makes the exception to be thrown. See http://jsfiddle.net/scorphus/ARTQ5/ for a brief demo. Hope it helps. |
Maximum Call Stack Exceeded When Destroying a nested model
test('Maximum call stack size exceeded with global models (#476)', function() { | ||
stop(); | ||
|
||
window.Character = can.Model.extend({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to use attributes / converters without adding to the window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interesting thing is that it worked when just passing the instances but the stack overflow happens when it is on the window using the string notation (Game.model
, Game.models
).
@thecountofzero checkout that last commit that shows how to avoid globals and use attributes. |
As reported by @thecountofzero here issue #324 doesn't seem to be completely fixed. Demos:
http://jsfiddle.net/thecountofzero/a2b3S/
http://jsfiddle.net/thecountofzero/8KX4N/7/
Here is the post on the forum:
http://forum.javascriptmvc.com/#Topic/32525000001308005