Debugging promises?


#1

EDIT: Never mind. I figured it out right after I posted this. How do I delete a thread?

I don’t care for promises. I find callbacks to work well enough. Luckily atom.workspace.open is the only source of promises I deal with.

When an exception is thrown while debugging I get no trace in the log. Flow just goes into promise land and disappears. This happens even deep in many nested calls.

Is there a way to debug exceptions in promises?


How do I delete a topic?
#2

I think this post could be quite helpful, Promises have been really trending and I doubt that anyone new to Promises will know how to deal with this immediately.

My rule of thumb on this matter: Never write a promises-based flow without a final fail/catch handler, it may feel redundant at first, but on the long run you’ll catch more bugs like that.

The second rule to consider, when the code get more stable: Never let a nested promises flow uncatched. This is a recurrent problem with Q and as Atom use it you’ll get bite by it sooner or later.

Finally, when using Q, there’s an option that tell Q to rebuild the stack trace by following which methods creates the promise and to recreates the promises flow in the stack trace (getting rid of the process.nextTick stuff). Useful for debugging but quite costly at runtime. I’ld love to see this integrated in standardized promises.


#3

I think both have their good points. I like to have my async methods allowing a callback while returning a promise. It integrates with either paradigm and make coding more dev-friendly (I can easily switch from one to the other according to my needs).


#4

As I usually only write “cold” code where time is not a concern, this sounds very useful. I will research it.


#5

Here’s the link to the documentation on this feat: https://github.com/kriskowal/q#long-stack-traces