News for hackers. Stuff that matters.
Re:Node v7.5.0 Released by norswap on Friday February 03, 2017 @07:56AM (#13559444)
Many people are complaining that the standard library still uses callbacks and so even though you have async/await, you can't use it with the standard library.

I wholeheartedly agree. I don't understand why someone hasn't build a compat library that simply promisifies all the standard library (it isn't that big), taking the edge cases into account.

Re:Node v7.5.0 Released by spion on Friday February 03, 2017 @08:09AM (#13559521)
Because the standard library doesn't really have that many callback based functions.

The more important issue here is that Promises are seen as fundamentally incompatible with post-mortem debugging due to their empty-the-stack requirement: https://promisesaplus.com/#point-34

If the stack is emptied when handling an exception, the context in which that exception happened is completely lost, so its not clear how to get the process to dump a core that contains meaningful information regarding the problem.

This is whats currently blocking node from fully switching to promises. Apparently many companies that have influence in node core rely heavily on post-mortem debugging and don't find the situation acceptable.

Re:Node v7.5.0 Released by jcheng on Friday February 03, 2017 @11:08AM (#13560760)
Both Q and bluebird promises optionally support long stack traces, albeit at a performance hit. And in practice even old style callbacks often (usually?) empty the stack.
Re:Node v7.5.0 Released by spion on Friday February 03, 2017 @09:12PM (#13565225)
No, old style callbacks don't empty the stack on thrown errors - they crash.

Long stack traces are fine, but post-mortem debugging means analyzing the entire program's core dump. That includes everything that was in the heap at the time, and not just the names of the functions on the stack but also their arguments (which often point to stuff in the heap). It can be used to reproduce most of the program state at the time of the crash.

The real problem is that at some point node decided that throw = programmer errors = core dump. This is wrong and misguided, but thats another story...

Re:Node v7.5.0 Released by Hurtak on Friday February 03, 2017 @09:02AM (#13559809)
From my experience majority of async functions that I used are from the fs package and for that, there is nice wrapper called fs-promise (1) which converts all the functions from callbacks to promises.

For other stuff, I just create my own promise wrapper (if I feel like that promise interface would be better), which is like 5 lines of code.

[1] https://www.npmjs.com/package/fs-promise

Re:Node v7.5.0 Released by rco8786 on Friday February 03, 2017 @08:05AM (#13559502)
There are like 10 of those, fwiw.
Re:Node v7.5.0 Released by alleycat on Friday February 03, 2017 @09:05AM (#13559827)
Re:Node v7.5.0 Released by ilaksh on Saturday February 04, 2017 @06:41PM (#13569781)
There are multiple that do that. `mz` is the most popular I know of.