Experiment: AsyncPromise, a Promise that captures 1 stack frame #11948
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Stack traces for async functions are often missing
This adds an internal Promise wrapper for async native functions which captures 1 stack frame and propagates it on promise rejection.
After:
Before:
Worth reading what v8 does
I don't think this PR's approach is quite right. This is only 1 stack frame, and only when using this special AsyncPromise in Zig/C++. It doesn't chain.
I think it'd be better to reuse the extra
context
argument in the await-specific code to have a reference to the StackFrame (though ideally without creating an additional JSCell)cc @dcrousso incase you find this interesting
I did a little benchmarking and couldn't find a measurable performance impact to this
How did you verify your code works?