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
BUG: Try-catches around callback execution #139
Comments
Hold your horses, my friend! =) This code is written in Streamline.js syntax (as mentioned in the readme): https://github.com/Sage/streamlinejs Streamline is a tool whose purpose is to let you write async JS as if it were synchronous — allowing you to use the full breadth of JS language features, including (Those two, for example, get compiled to IOW, this library is explicitly designed to do error handling correctly, and AFAIK, it does. If you've encountered a case where it doesn't, that's definitely a bug by oversight, not behavior by design. In the example you give, for instance, when I run it locally, the stack trace seems fine:
I'm really sorry you ran into this issue and had to sink an hour into debugging it. Is the example you gave representative of what you ran into? Or was it more complex than that? |
Perhaps I'm mischaracterizing the problem, but can you explain what's going in / causing that gnarly stacktrace? You're right, my simplified example doesn't seem to reproduce the problem. Regardless, after using node-neo4j, I reach a point in the application where if I run: console.log(typeof undefinedfunction); // prints out "undefined"
undefinedfunction(); It will throw with a stacktrace like before:
If I comment out the line at fault,
The error disappears. Something, somewhere is getting caught incorrectly by streamline / node-neo4j. I'll dig into it more and see what I can find. |
I agree that there's a bug with the stack trace — the first line of the stack trace should point to your code, not node-neo4j's. Just to confirm, is that the crux of the issue to you too? Off the top of my head, I don't know what would cause that. I'm doing some playing around with code and can't reproduce that either. Could you perhaps share some more of your real code that's hitting this? |
Yeah, that's the crux – the library shouldn't have any influence once it has passed off control. Here is something small that reproduces the same exception: neo4j.query('MATCH a->[rel]->b', {}, function() {
neo4j.query('MATCH a->[rel]->b', {}, function() {
console.log('done');
});
var a = somethingundefined;
});
|
Hmm... still works fine for me:
Question: can you share the output of running this? cd node_modules/neo4j
npm ls |
On node v0.10.26 w/ |
Hmm, your dependencies look good. One thing we could try is manually recompiling your node-neo4j with the latest Streamline, as I see that the compiled version in npm was from a reasonably older version of Streamline now. # within node_modules/neo4j still:
npm run clean
npm run build Do things work for you then? If so, great that we found the cause — I'll re-publish to npm with a re-compile to make sure others don't run into this too. |
Still no dice.
|
Hmm, your shell snippet shows |
Good catch – there was something funny going on there. I just fixed that up and voilà – it works. Looks like streamline was the one to blame. Thanks for sticking with this, I appreciate it.
Footnote: A bit of a religious question here: why not drop CoffeeScript and streamline? Don't they create unneeded complexity for questionable gains? |
Great that recompiling fixed it! I'll re-compile and re-publish soon then. Re: why CoffeeScript & Streamline: yep, it's subjective, but to my taste (and having written code with and without both), the gains they provide are substantial. It's hard to really convey this without trying it out for yourself, but I prepared a presentation on this for CoffeeScript a while back: http://aseemk.com/talks/intro-to-coffeescript I've yet to do something similar for Streamline, but really want to. |
Keeping this issue open for myself to re-compile and re-publish. |
Ah, this topic saved my day! :) |
+1 I have the same issue |
@aseemk when you plan to provide a hotfix release? This bug makes your module broken on all windows platforms. It's event not possile to dev with it. Btw, this is the real reason to avoid CoffeeScript: https://donatstudios.com/CoffeeScript-Madness |
Sorry for the delay, things have been busy. I will republish tonight. |
Thanks a lot! |
It is a really bad practice to throw exceptions inside of async code and right now node-neo4j is littered with this. Even worse, there are try/catches around where user callbacks are executed. Can both of these things be fixed? (Edit: Not the problem because of code transformation through streamline) I would offer to refactor, but it's in CoffeeScript (another discussion).
Why is it bad? It makes debugging of exceptions completely unrelated to node-neo4j nearly impossible (just spent an hour doing it). For example, here is a stack trace:
The cause: an
undefined
function elsewhere in the application.Here's a simplified scenario:
In this example, the TypeError gets caught by neo4j and fails erratically with a stack trace like above.
The text was updated successfully, but these errors were encountered: