GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bindings: adding process.binding('builtins') method by thlorenz · Pull Request #2180 · nodejs/node

Conversation

@thlorenz

@thlorenz thlorenz commented Jul 14, 2015

Copy link
Copy Markdown
Contributor
  • this method traverses the modlist_builtin linked list and returns an
    object which has binding names as keys and their versions as values

Sample Output:

➝  ./node
> process.binding('builtins')
{ tls_wrap: 44,
  crypto: 44,
  uv: 44,
  udp_wrap: 44,
  process_wrap: 44,
  tty_wrap: 44,
  timer_wrap: 44,
  tcp_wrap: 44,
  stream_wrap: 44,
  spawn_sync: 44,
  smalloc: 44,
  signal_wrap: 44,
  pipe_wrap: 44,
  zlib: 44,
  v8: 44,
  os: 44,
  http_parser: 44,
  fs: 44,
  contextify: 44,
  buffer: 44,
  js_stream: 44,
  cares_wrap: 44,
  fs_event_wrap: 44,
  async_wrap: 44 }

This is in a sense the binding counter part to process.binding('natives'), except for bindings and the fact that it doesn't include any sources.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thlorenz
bindings: adding process.binding('builtins') method
4d5011a
- this method traverses the `modlist_builtin` linked list and returns an
  object which has binding names as keys and their versions as values
@brendanashworth brendanashworth added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jul 14, 2015
@trevnorris

trevnorris commented Jul 14, 2015

Copy link
Copy Markdown
Contributor

All of these will always have the same version. It might make more sense to do something like

{  version: 44,
   bindings: [<list>]
}

/cc @bnoordhuis
Am I correct in that assumption?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 14, 2015

Copy link
Copy Markdown
Contributor Author

I wasn't sure about the meaning of the versions, but I figured they could be different (why else would each binding have one).
I could change this to an array or include a bindings hash which adds different values, i.e. file_path.
Not sure if that information would be useful though.

If we return a bindings array we may also exclude the version info all together, i.e. just return an Array instead of an Object. Again I'm not sure of the importance/significance of the version field.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jul 14, 2015

Copy link
Copy Markdown
Contributor

@thlorenz The version is the same as defined as NODE_MODULE_VERSION in src/node_versions.h.

Since developers can get the module version as process.versions.modules I'd say just make an array and leave out other information.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 14, 2015

Copy link
Copy Markdown
Contributor Author

Sounds good, will update the PR tomorrow.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin

vkurchatkin commented Jul 15, 2015

Copy link
Copy Markdown
Contributor

@thlorenz may I ask, what is it for? process.binding is private so it doesn't expose any new functionality to the users

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 15, 2015

Copy link
Copy Markdown
Contributor Author

@vkurchatkin this is just to get a list of builtin bindings in case you need to know that information.
However you can only read that list (of strings), but not access the bindings or their source.
So it doesn't expose any functionality per se.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 15, 2015

Copy link
Copy Markdown
Contributor Author

@trevnorris

I'd say just make an array and leave out other information.

Realized that the exports defined here is always an Local<Object>.
So trying to return a Local<Array> just for this special case seems inconsistent and would make that one extra code path very different from all other else if paths since we couldn't use this value return.

So for sake of consistency and simplicity I'll create an object instead with bindings property like you suggested before (except without the version as that is easily retrieved via process.versions.modules).
Returning an object has the added benefit that we could add more information via extra properties later without breaking backwards compatibility.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz
fixup! bindings: adding process.binding('builtins') method
5651e0c
@thlorenz

thlorenz commented Jul 15, 2015

Copy link
Copy Markdown
Contributor Author

Adapted the implementation to return the following:

➝  ./node
> process.binding('builtins')
{ bindings:
   [ 'tls_wrap',
     'crypto',
     'uv',
     'udp_wrap',
     'process_wrap',
     'tty_wrap',
     'timer_wrap',
     'tcp_wrap',
     'stream_wrap',
     'spawn_sync',
     'smalloc',
     'signal_wrap',
     'pipe_wrap',
     'zlib',
     'v8',
     'os',
     'http_parser',
     'fs',
     'contextify',
     'buffer',
     'js_stream',
     'cares_wrap',
     'fs_event_wrap',
     'async_wrap' ] }
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jul 15, 2015

Copy link
Copy Markdown
Member

I don't see the point. process.binding() is internal, the list of bindings can and will change over time, and core doesn't have a need for it in the first place.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 15, 2015

Copy link
Copy Markdown
Contributor Author

@bnoordhuis

the list of bindings can and will change over time

That's exactly why it'd be useful if users could get a list of the bindings implemented in the version that they are using.

I understand that core itself may have no need for this feature, but this info is very useful for specific tooling (at least it is in my case) and I thought adding it would help others who need it as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bmeck

bmeck commented Jul 15, 2015

Copy link
Copy Markdown
Member

I know binding('natives') is used to fast path and prevent overriding natives, with the new loaded bindings wouldn't this make sense to do the same check but on bindings?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 15, 2015

Copy link
Copy Markdown
Contributor Author

If adding this to process.binding is the problem would it be preferable to expose this information in another way?
Don't want to pollute process though, so not sure where else it could go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Qard

Qard commented Jul 17, 2015

Copy link
Copy Markdown
Member

Everything available through process.binding() is intended only for internal use. The API is not guaranteed to be stable.

Userland should not have any reason to be using bindings directly. If they do, they are almost certainly doing the wrong thing and should be making a PR or feature request to expose the thing they need properly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thlorenz

thlorenz commented Jul 21, 2015

Copy link
Copy Markdown
Contributor Author

I get all the arguments, but if a tool needs that info it'd be very useful to get it this way instead of hard coding it somewhere or traversing the src folder and guessing which of these are bindings.
There is actually a module out there (can't find it currently) that's just JSON files containing a list of core modules and bindings.
Basically I want to avoid having to resort to those methods via a simple change here.

However if no one else has that need I'm ok with closing this PR and get that info the hacky way :(

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin

vkurchatkin commented Jul 21, 2015

Copy link
Copy Markdown
Contributor

My primary concern is that adding something to bindings like this makes it look like this is actually supposed to be used. Making this public is also not an option, because having a public list of internal stuff doesn't make much sense

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Qard

Qard commented Jul 21, 2015

Copy link
Copy Markdown
Member

But why would a tool need that? I'm not seeing the use case. Do you have something in particular in mind?

(Not trying to discount the value, just saying that I'm not seeing what exactly the value is.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bmeck

bmeck commented Jul 21, 2015

Copy link
Copy Markdown
Member

I for one like the ability of having check if something exists if I use process.binding (lets face it people do use it / it does not have an underscore). I am sure some APM out there is doing things with process bindings, but lack real world examples.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny
indutny force-pushed the master branch from bffb204 to eb35968 Compare July 22, 2015 21:21
@rvagg
rvagg force-pushed the master branch from 11c25c2 to ba02bd0 Compare September 6, 2015 11:55
This was referenced Oct 20, 2015
Expose up-to-date list of builtin modules #3307
Closed
node: deprecate public access to process.binding #2768
Closed
@jasnell

jasnell commented Nov 16, 2015

Copy link
Copy Markdown
Member

@thlorenz ... is this still something you'd like to pursue?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Nov 16, 2015
@Trott
Trott force-pushed the master branch from 1e896a6 to 082cc8d Compare December 27, 2015 02:00
@jasnell

jasnell commented Mar 22, 2016

Copy link
Copy Markdown
Member

Closing due to lack of activity or response.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Mar 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. stalled Issues and PRs manually marked as stalled and scheduled for automatic closure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@thlorenz @trevnorris @vkurchatkin @bnoordhuis @bmeck @Qard @jasnell @brendanashworth
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.