Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Co throws when no callback provided #133

Closed
kof opened this issue Jul 12, 2014 · 16 comments · Fixed by #154
Closed

Co throws when no callback provided #133

kof opened this issue Jul 12, 2014 · 16 comments · Fixed by #154

Comments

@kof
Copy link

kof commented Jul 12, 2014

Co throws an error when no done callback provided.

  1. There are mostly examples without any callback
  2. Throwing error means it will land as uncaughtException

First of all its a documentation issue. But I think throwing errors is not a solution at all. Instead done callback should be non optional parameter.

@kof
Copy link
Author

kof commented Jul 12, 2014

Oh I see why you did an optional callback .... because you expect that everything within co is wrapped with try/catch ... hmmm

@kof
Copy link
Author

kof commented Jul 12, 2014

I am not sure what to do to avoid other people trap on this like me. First of all better documentation of the done callback. And probably all examples should use try/catch within co?

@tj
Copy link
Owner

tj commented Jul 12, 2014

probably just better docs, no point doing try/catch within co since co itself acts like a big try/catch, just propagates by default but I think that's better than the error getting lost in limbo. maybe when promises are everywhere we just return a promise and do whatever they do (what does a promise do if it has no handler? just wait until there is one?)

@jonathanong
Copy link
Contributor

if i have a question related to promises, i always ping @domenic!

@kof
Copy link
Author

kof commented Jul 12, 2014

Regarding to promises, we have them already in 0.11 harmony version where generators actually work. So we can actually use the global Promise object.

@jonathanong
Copy link
Contributor

there are apparently some bugs with it. we could always "look for a promise library" if one isn't available and except users to include their own

@kof
Copy link
Author

kof commented Jul 12, 2014

which bugs? can you point me?

@kof
Copy link
Author

kof commented Jul 12, 2014

I mean as far as then and catch works as expected, it should be ok.

@iliakan
Copy link
Contributor

iliakan commented Jul 12, 2014

I've read somewhere in docs that "co must be used in real life only with a callback". That saved some of my time when I learned it, but wasn't obvious from the examples.

Maybe it's worth to use a callback in examples too.

@tj
Copy link
Owner

tj commented Jul 12, 2014

I'm -1 on promises until it's the v8 impl and it's decent

@kof
Copy link
Author

kof commented Jul 12, 2014

the question is what's wrong with the current Promise object in v8.

@tj
Copy link
Owner

tj commented Jul 12, 2014

I haven't used them, I've heard they're super slow but that's alright I guess as long as they're not broken, not a real bottleneck anyway

@iliakan
Copy link
Contributor

iliakan commented Jul 12, 2014

My 5cents: I've heard current V8 promises are not up2date with the spec.

People suggest to use bluebird.

@domenic
Copy link

domenic commented Jul 15, 2014

V8 promises are up to date.

The version of V8 that ships with Node 0.11 has a minor bug where it handles invalid arguments incorrectly.

The biggest problem is nodejs/node-v0.x-archive#7714 which is a Node bug.

@kof
Copy link
Author

kof commented Jul 15, 2014

@domenic looks also like a minor issue to me, no?

@domenic
Copy link

domenic commented Jul 15, 2014

@kof not really; using promises + setTimeout + nextTick can be pretty common (e.g. test runners testing a promise API). Once all three of those ingredients are present in a program, things break pretty massively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants