Skip to content

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

Merged
TimothyGu merged 1 commit into
nodejs:masterfrom
TimothyGu:promise-inspect
Apr 8, 2017
Merged

util: use V8 C++ API for inspecting Promises#12254
TimothyGu merged 1 commit into
nodejs:masterfrom
TimothyGu:promise-inspect

Conversation

@TimothyGu

@TimothyGuTimothyGu commented Apr 6, 2017

Copy link
Copy Markdown
Member

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

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. util Issues and PRs related to the built-in util module. labels Apr 6, 2017
@mscdexmscdex added the promises Issues and PRs related to ECMAScript promises. label Apr 6, 2017
Comment threadlib/util.js Outdated

Copy link
Copy Markdown
Member

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…

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

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.

@joshgavjoshgav left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/node_util.cc Outdated

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
MemberAuthor

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>
@TimothyGu

TimothyGu commented Apr 8, 2017

Copy link
Copy Markdown
MemberAuthor

@TimothyGu
TimothyGu merged commit a37273c into nodejs:masterApr 8, 2017
@TimothyGu
TimothyGu deleted the promise-inspect branch April 8, 2017 18:54
@TimothyGu

Copy link
Copy Markdown
MemberAuthor

Landed in a37273c.

@italoacasas

Copy link
Copy Markdown

cc @TimothyGu

@addaleax

Copy link
Copy Markdown
Member

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

@jasnelljasnell mentioned this pull request May 11, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.promisesIssues and PRs related to ECMAScript promises.utilIssues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@TimothyGu@italoacasas@addaleax@bnoordhuis@evanlucas@Fishrock123@cjihrig@joshgav@mscdex@nodejs-github-bot