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
Out of stack space error in IE #502
Comments
I get this error too. The specific error is: " Unable to get value of the property 'appendChild': object is null or undefined" thrown from runner.on('test end':
for some reason stack is [] |
@liammclennan that also happens to me sometimes after I get the stack space error on IE and refresh |
we're getting this error in IE10 as well. does anyone have any clue what's going on? is this a design problem in mocha using recursion to run tests, under a limited stack frame environment? or ??? any help is appreciated, as we are running in to what looks like a limit of around 20 the problem we're seeing is that the tests complete (pass or fail), and then trying to report the problem fails at line 1753:
|
Uh oh. EpicEditor is nearing over 100 tests as well and @johnmdonahue and I were going to switch over to Mocha. I'll be keeping an eye on this ticket. |
i've spent the better part of the day trying to track this problem down, and here's what i've come up with: Mocha uses recursion to run the specs. I'm seeing the It looks like the stack is reset at the beginning of each file, some times... but at other times it looks like it is a cumulative stack for all files. It's quite confusing and I'm having a hard time understanding what circumstances would cause such a deep stack trace, especially when the file that finally runs in to this problem only had 3 "describe" and 6 "it" blocks in it. trying to dig in to this further, but any help from @visionmedia would be greatly appreciated. i don't want to have to go back to jasmine with it's awful "waitsFor" and "runs" methods for async support. |
that's why we have some next ticks in there to kill the stack, we just need a few more I guess |
I haven't seen this myself personally though, maybe im not writing enough tests haha |
next update... i figured out that the scenario in which i thought recursion was due to a new file, was due to a suite of async tests and them not completing before some synchronous tests. that made me thing: a deep stack trace can be cut by using any async call to push something to the back of the javascript timer/queue (whatever that's called). a simple The WorkaroundAt the beginning of every .spec file, just inside of your wrapping describe("the contents of this file", function(){
// blow away the stack trace here
beforeEach(function(done){
setTimeout(done, 0);
});
// do my tests here
describe("whatever", function(){
// ...
});
// do my tests here
describe("whatever", function(){
// ...
});
// do my tests here
describe("whatever", function(){
// ...
});
}); The potential problem with this workaround, is that if you have a large spec file with many "describe" and "it" blocks in it, or a deep stack trace due to your own code, you can still run in to this problem. The continued workaround for that, though, is to call At least this is a workaround for now, as ugly as it is. Can we get a legit fix to this, though? The specs shouldn't be called recursively, IMO. Is there a reason that it was designed this way? |
an even better work around: create a helper.js file (or open the one you already have) and just put the this way you only have to do it once, not in every file. it will get run before all of your specs and you'll never have to worry about this again. |
nothing is wrong with recursion at all, we just need to drop the stack every so often, recursion simplifies many things internally |
while i agree with the first part of that on it's own, when the qualification of the second part is a necessity, then recursion is not an appropriate solution for the situation. ... but... yeah :) a fix in Mocha would be awesome. the setTimeout trick works for now. |
when you can nextTick in a tiny fraction of a second it's not an issue, implementing actions against a tree like we have here would get very messy when combined with async callback crap all over, if we used coroutines then yeah maintaining our own stack would be fine |
@derickbailey thanks for the quick fix, gonna apply that until this issue is resolved |
Any plans to fix this soon? This seems to kill our test suite in IE8 completely. The IE process takes 1.5 GB of memory and then fails with an out of memory error. The setTimeout workaround didn’t help. I know no-one here cares about old IEs, but any real-world client-side JavaScript has to. |
I dont have any windows vms going so I can't test it unfortunately, not any time soon at least. When I get my old MBP fixed I'll chuck ugly old windows on there |
The workaround fixed the tests in IE (kamicane/prime@762be12) |
The problem is that process.nextTick doesn't kill the stack in IE. Here is an implementation which does: process.nextTick = (function(){
var timeouts = []
// postMessage behaves badly on IE8
if (window.ActiveXObject || !window.postMessage) {
return function(fn){
timeouts.push(fn);
setTimeout(function(){
if (timeouts.length) timeouts.shift()();
}, 0);
}
}
// based on setZeroTimeout by David Baron
// - http://dbaron.org/log/20100309-faster-timeouts
var name = 'mocha-zero-timeout'
window.addEventListener('message', function(e){
if (e.source == window && e.data == name) {
if (e.stopPropagation) e.stopPropagation();
if (timeouts.length) timeouts.shift()();
}
}, true);
return function(fn){
timeouts.push(fn);
window.postMessage(name, '*');
}
})(); It also fix issue #737. |
I found this while Googling for an appropriate mechanism for resetting IE8's stack for one of my projects. While If anyone figures out a way to clear the stack in IE8 and trigger the callback immediately, let me know. Conversely, if I find anything, I'll update here. |
I found this project: They have a solution for IE6-8, which is quite the hack: It inserts a script into the page with a |
+1 |
Due to mochas recursion IE tests fail due to `out of stack space`. mochajs/mocha#502
I believe this is no longer an issue, with the current version of mocha. If I'm mistaken, please comment and I'll re-open. |
Large amounts of tests often cause "out of stack space" errors in Internet Explorer (IE <= 9).
After analyzing the call stack when the error is thrown, it is huge!
If I let the tests "breath":
.. all is fine.
The project in which this is happening has 258 asserts and a total of 102 tests.
The text was updated successfully, but these errors were encountered: