Skip to content
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

Node 12 "async" annotations are lost when using this package #243

Open
alcuadrado opened this issue May 28, 2019 · 3 comments
Open

Node 12 "async" annotations are lost when using this package #243

alcuadrado opened this issue May 28, 2019 · 3 comments

Comments

@alcuadrado
Copy link

alcuadrado commented May 28, 2019

Node 12 added some limited support for async stack traces. I'm impressed that this package supports them, but it removes a useful annotation from them:

Given this file:

function p() {
  return new Promise(resolve => setTimeout(resolve, 0))
}

async function f() {
  await p()
  throw Error("")
}

async function main() {
  await f()
}

main()
  .catch(console.error)

The stack traces without registering source-map-support is:

Error
    at f (/private/tmp/async-stack-traces/index.js:9:9)
    at async main (/private/tmp/async-stack-traces/index.js:13:3)

With source-map-support registered is:

Error:
    at f (/private/tmp/async-stack-traces/index.js:9:9)
    at main (/private/tmp/async-stack-traces/index.js:13:3)

I think the async annotation there is useful, as this stack trace is not the actual one as seen by v8, but an augmented one. This augmentation doesn't always work, and it would be surprising to the user if they look like normal stack traces.

@justinmchase
Copy link

Can confirm, this is super confusing as I wasn't sure what was causing it and I wasn't sure if my stack traces were actually working. Several hours later I found this issue.

@LinusU
Copy link
Collaborator

LinusU commented Nov 16, 2020

Would love a PR addressing this 🚀

@cspotcode
Copy link

cspotcode commented Jul 20, 2021

To fix this, the implementation of CallSiteToString -- which is copy-pasted from V8 source code -- must be updated to match the latest V8 implementation.

https://github.com/v8/v8/blob/dc712da548c7fb433caed56af9a021d964952728/src/objects/stack-frame-info.cc#L344-L393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants