Skip to content

Commit

Permalink
Added test that causes Maximum call stack size exeeded error in node
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Dec 6, 2014
1 parent 3844978 commit 650a417
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions test/tests/extension-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2524,25 +2524,21 @@ describe("Thenables should not be able to run code during assimilation", functio
describe("on node 0.10.x, using process.nextTick recursively shows deprecation warning. setImmediate should be used instead.", function() {
// (node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

specify("should not throw an error", function (done) {
var promises = [];

for (var i = 0; i < 1000; i++) {
var A = require('../../dist/rsvp').Promise;
var B = require('../../dist/rsvp-2').Promise;
var promise = new Promise(function(resolve){
A.resolve().then(function() {
B.resolve().then(function() {
A.resolve().then(function(){
resolve();
});
});
specify("should not cause 'RangeError: Maximum call stack size exceeded'", function (done) {
var depth = 0;
var nextTick = function(promise) {
if (depth < 500) {
promise.then(function(){
process.nextTick(function(){
depth++;
nextTick(promise);
})
});
});
promises.push(promise);
}
}
return promise;
};

RSVP.all(promises)
nextTick(RSVP.resolve())
.then(function(){
done();
});
Expand Down

0 comments on commit 650a417

Please sign in to comment.