You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just faced an issue mixing generators and yield*, co, and node.
It seemed to be the right place to start, but I'm not really sure this is a problem with co.
Let me explain:
I usually use this code to make the node task fail whenever an error occurs in a generators chain handled by co, because of Promise specification, where errors are muted if not handled:
I also find yield* a cleaner way to yield the values returned by an array of promises, instead of Promise.all().
At first, I thought that it pretty did the same thing as Promise.all(), but when one of the promises is rejected, then I had the following error:
/somewhere/yield.js:14
throw reason;
^
unhandled TypeError: Cannot read property 'done' of undefined
at next (/somewhere/node_modules/co/index.js:98:14)
at onRejected (/somewhere/node_modules/co/index.js:85:7)
....
I use Node 6.3.1 and co 4.6.0. http://node.green/#generators tells that yield* is fully supported by Node...
If you have any thoughts on this, I'll be glad to know :)
The text was updated successfully, but these errors were encountered:
You can only use yield* to delegate to other generators in co. The reason is that the throw call (made by co because of the rejected promise) is propagated to the array iterator and this iterator does not implement a throw method.
I just faced an issue mixing generators and
yield*
, co, and node.It seemed to be the right place to start, but I'm not really sure this is a problem with co.
Let me explain:
I usually use this code to make the node task fail whenever an error occurs in a generators chain handled by co, because of
Promise
specification, where errors are muted if not handled:I also find
yield*
a cleaner way to yield the values returned by an array of promises, instead ofPromise.all()
.At first, I thought that it pretty did the same thing as
Promise.all()
, but when one of the promises is rejected, then I had the following error:Here is the full code:
https://gist.github.com/rehia/6b13bd8202a37fbb58c82cbdd9df9b83
I use Node 6.3.1 and co 4.6.0.
http://node.green/#generators tells that
yield*
is fully supported by Node...If you have any thoughts on this, I'll be glad to know :)
The text was updated successfully, but these errors were encountered: