Skip to content

Instantly share code, notes, and snippets.

@codahale
Created February 27, 2011 03:18
Show Gist options
  • Save codahale/845874 to your computer and use it in GitHub Desktop.
Save codahale/845874 to your computer and use it in GitHub Desktop.
~/Downloads/node-v0.4.1> less pop-stack.js
function doAThing(i) {
console.log("Iter " + i);
doAThing(i + 1);
}
doAThing(1); // this should be good
~/Downloads/node-v0.4.1> ./node pop-stack.js
Iter 1
Iter 2
...
Iter 676
Iter 677
Iter
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
undefined
@lmorchard
Copy link

Try process.nextTick(function () { doAThing(i+i); }) instead?

And yeah, after seeing more on twitter, it's kind of despairingly silly to have to do this.

@xergio
Copy link

xergio commented Dec 11, 2014

process.nextTick is deprecated, use setImmediate instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment