-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
util: use V8 C++ API for inspecting Promises #12254
Conversation
var str = formatValue(ctx, internals.value, nextRecurseTimes); | ||
if (internals.status === 'rejected') { | ||
var str = formatValue(ctx, result, nextRecurseTimes); | ||
if (state === binding.kRejected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fyi @Fishrock123, this seems like a cleaner way to inspect Promise states than what the abort-on-rejected PR currently does…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errr, this allows you to get the actual result object e.g. an error without going through the Debug API? I was told that was not possible to do synchronously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fishrock123 this set of APIs is relatively new, having been added in V8 5.7 in v8/v8@2843258. That might be why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but perhaps returning an object instead of an array would be better.
auto isolate = args.GetIsolate(); | ||
|
||
Local<Promise> promise = args[0].As<Promise>(); | ||
Local<Array> ret = Array::New(isolate, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might it be better to use Object and name the properties? might be easier if we want to extend with additional metadata, and would allow the JavaScript to be de-coupled from the order of items in the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the fact that this is simpler to implement, it is also the approach taken by the existing GetProxyDetails
. Plus, I don't think it is very likely for promises to change its internal properties anytime soon.
PR-URL: nodejs#12254 Refs: nodejs#11875 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Josh Gavant <josh.gavant@outlook.com>
fa77241
to
a37273c
Compare
Landed in a37273c. |
cc @TimothyGu |
This depends on V8 5.7 iiuc, so I’m adding the dont-land labels here |
Avoid using the deprecated debug mirror API.
Refs: #11875
Refs: #12243
CI: https://ci.nodejs.org/job/node-test-pull-request/7244/
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url