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

util: use V8 C++ API for inspecting Promises #12254

Merged
merged 1 commit into from Apr 8, 2017

Conversation

@TimothyGu
Copy link
Member

commented Apr 6, 2017

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), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

url

var str = formatValue(ctx, internals.value, nextRecurseTimes);
if (internals.status === 'rejected') {
var str = formatValue(ctx, result, nextRecurseTimes);
if (state === binding.kRejected) {

This comment has been minimized.

Copy link
@addaleax

addaleax Apr 6, 2017

Member

Also fyi @Fishrock123, this seems like a cleaner way to inspect Promise states than what the abort-on-rejected PR currently does…

This comment has been minimized.

Copy link
@Fishrock123

Fishrock123 Apr 6, 2017

Member

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.

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu Apr 6, 2017

Author Member

@Fishrock123 this set of APIs is relatively new, having been added in V8 5.7 in v8/v8@2843258. That might be why.

@cjihrig
cjihrig approved these changes Apr 6, 2017
@joshgav
Copy link
Member

left a comment

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);

This comment has been minimized.

Copy link
@joshgav

joshgav Apr 7, 2017

Member

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.

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu Apr 7, 2017

Author Member

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.

@TimothyGu TimothyGu referenced this pull request Apr 7, 2017
4 of 4 tasks complete
util: use V8 C++ API for inspecting Promises
PR-URL: #12254
Refs: #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>
@TimothyGu

This comment has been minimized.

@TimothyGu TimothyGu force-pushed the TimothyGu:promise-inspect branch to a37273c Apr 8, 2017

@TimothyGu TimothyGu merged commit a37273c into nodejs:master Apr 8, 2017

12 checks passed

linter no errors found
Details
test/aix all tests passed
Details
test/arm all tests passed
Details
test/arm-fanned all tests passed
Details
test/freebsd all tests passed
Details
test/linux all tests passed
Details
test/linux-fips all tests passed
Details
test/linux-one all tests passed
Details
test/osx all tests passed
Details
test/ppc-linux all tests passed
Details
test/smartos all tests passed
Details
test/windows-fanned all tests passed
Details

@TimothyGu TimothyGu deleted the TimothyGu:promise-inspect branch Apr 8, 2017

@TimothyGu

This comment has been minimized.

Copy link
Member Author

commented Apr 8, 2017

Landed in a37273c.

@italoacasas

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

@addaleax

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

This depends on V8 5.7 iiuc, so I’m adding the dont-land labels here

@jasnell jasnell referenced this pull request May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.