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

expose process.binding('util').getPromiseDetails #3

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

seanwentzel
Copy link
Member

This merges the internalBinding for util and the Node 16+ external binding. Some methods are defined in both
and I haven't checked very carefully what happens with those, but they are all isType methods (eg isPromise)
so it would be pretty buggy if their behavior differed.

test plan:
build node, and verify I can access getPromiseDetails and use it to check if a promise is resolved

@seanwentzel
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@seanwentzel
Copy link
Member Author

manual testing:

> prom = Promise.resolve(3)
Promise {
  3,
  [Symbol(async_id_symbol)]: 265,
  [Symbol(trigger_async_id_symbol)]: 6
}
> ut.getPromiseDetails(prom)
[ 1, 3 ]
> prom2 = new Promise();
Uncaught TypeError: Promise resolver undefined is not a function
    at new Promise (<anonymous>)
> prom2 = new Promise(() => {})
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 651,
  [Symbol(trigger_async_id_symbol)]: 6
}
> ut.getPromiseDetails(prom2)
[ 0 ]
> ut.constants
{
  kPending: 0,
  kFulfilled: 1,
  kRejected: 2,
  ALL_PROPERTIES: 0,
  ONLY_WRITABLE: 1,
  ONLY_ENUMERABLE: 2,
  ONLY_CONFIGURABLE: 4,
  SKIP_STRINGS: 8,
  SKIP_SYMBOLS: 16
}

// We need getPromiseDetails and constants.kFulfilled from `internalBinding('util')`
return {
...legacy,
...internalBinding('util'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@seanwentzel seanwentzel merged commit bc56465 into v18 Jan 8, 2024
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants