“Generator already running” message on any error

2019-09-06 00:44发布

问题:

I have a very simple generator function, like this

exports.whatever = function *(next) {
  this.body = 'wow';
  z
};

Now, there obviously is a syntax error here ('z' on the third line), but with koa's generators, the error I get in the console is basically useless for debugging; I do not get the line of the error, the file, or even the type of error. All I get is:

Error: Generator is already running
    at GeneratorFunctionPrototype.next (native)
    at onFulfilled (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:59:19)
    at /Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:48:5
    at Object.co (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:47:10)
    at Object.toPromise (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:112:63)
    at next (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:93:29)
    at onRejected (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:79:7)

Is there any way to see the real detail of the error? Thanks in advance.