Skip to content

Conversation

seanwentzel
Copy link

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
Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@seanwentzel
Copy link
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
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.

3 participants