60

We're experimenting with using --harmony_async_await in Node 7, and compared to transpiling with babel for async/await are missing the ability to have long stack traces (http://bluebirdjs.com/docs/api/promise.longstacktraces.html).

Obviously, it would be great if there was an option to 'just see this' - on the chrome(ium) side they appear to support it in the inspector, though the latest work on this is after v8.5.4 (i.e. not in Node 7):

https://bugs.chromium.org/p/v8/issues/detail?id=4483

https://codereview.chromium.org/2357423002/

An alternative approach would be to get v8 to use bluebird's promise implementation - but how could I do that? Overriding global. Promise doesn't change how async/await behave (they still use the default promises).

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
james.haggerty
  • 1,170
  • 6
  • 10
  • Interestingly, Emanuel Jöbstl suggests that replacing the built-in promise implementation which you mention actually works! https://medium.com/front-end-weekly/stack-traces-for-promises-in-node-js-46bf5f490fe4. – kresho Feb 01 '19 at 14:50
  • 3
    Replacing the promise implementation to bluebird and enabling full stack traces incurs a high performance hit 4x-5x (https://github.com/nodejs/node/issues/11865#issuecomment-325035479) – kresho Feb 01 '19 at 15:32
  • 10
    But node 12 finally provides native support - https://docs.google.com/document/d/13Sy_kBIJGP0XT34V1CV3nkWya4TwYx9L3Yv45LdGB6Q/edit – kresho Feb 01 '19 at 15:33
  • 1
    @kresho thanks for letting me (and everyone else) know! Perhaps something changed since I'd messed with it, or I just made a mistake. Node/v8 have certainly come a long way since this question was asked. – james.haggerty May 19 '19 at 09:43
  • the feature was announced in December 2018, about a month after your question :-). Public release was on 23/4/2019, so still quite fresh. – kresho May 20 '19 at 08:42
  • 7
    Question was from 2016 :) – james.haggerty Nov 20 '19 at 02:31

1 Answers1

1

Since NodeJS v12 async stack traces are enabled by default.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151