Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
'Maximum call stack size exceeded' in 'co'
'use strict';
/*global console*/
// co version 3.0.6
var co = require('co');
function task(callback) {
callback(null, 1);
// 10000 will throw a 'Maximum call stack size exceeded' error
co(function *(){
for (var i = 0, l = 10000; i < l; i++) {
yield task;

This comment has been minimized.

Copy link
Owner Author

@zensh zensh commented Jun 1, 2014

由于 co 的 error 是异步抛出,所以看不到Maximum call stack size exceeded,若想看必须在 co 内部console


This comment has been minimized.

Copy link

@hax hax commented Jun 1, 2014


function task(callback) {
  setImmediate(function () { callback(null, 1) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment