Skip to content

Correct/ Canonical way to preserve stack context when rejecting promises? #1124

Answered by bnoordhuis
caturria asked this question in Q&A
Discussion options

You must be logged in to vote

When native code returns a promise and later wants to reject it, is there a recommended way of preserving the call stack?

Not at the moment. What you're currently doing is not a bad solution.

We could add a C API that lets you capture the stack trace so you don't have to create and manipulate a dummy Error object, or we could add a (opt-in because of overhead) mode that automatically captures stack traces at await points and stitches them together into a single long stack trace.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by caturria
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants