4

Basically, I have the same question as this but for node 16+. The bottom of that answer says:

On Node 14+ you can use --async-stack-traces flag to have an improved stack trace when working with asynchronous code. There are some limitations like only working with async/await and not promises.

You can read a little bit more about this at https://v8.dev/blog/fast-async

I'm using v16.13.2, and I can't see anything about this flag when I type node -h | grep async. Yet, my stack traces are limited to synchronous stacks like the person asking the question. I understand why, but I want to know if there is a way to get better troubleshooting information.

Was the concept of --async-stack-traces scrapped? Was it replaced with something else? Is there any way to see asynchronous stack traces in Node 16+? If so, how is it done?


Update: I found a helpful comment in this github issue: node --v8-options | grep async So I guess this flag does exist in 16, but I don't really know how to turn it on, especially when my package.json is full of scripts, none of which use node directly (Jasmine, Testcafe, Typescript, ts-node).


Update: I'm even more confused after finding this comment.

This flag is enabled by default in V8. You do not need to pass it.

See here for proof: https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/deps/v8/src/flags/flag-definitions.h#L1730

This doesn't seem like it to me... There must be something specific to the library I'm using.


Update: Turns out I've been experiencing a Test Café bug this whole time. It had nothing to do with this flag (which is on by default). I suppose this information suffices as an answer.

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

1 Answers1

3

You can find the answer to this question in my updates above, but to summarize:

  1. This flag still exists, but the only way to list it is to run node --v8-options
  2. This flag is on by default.
  3. My symptoms were a testcafe bug that coincidentally matched what you would see if async stack traces were off.
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356