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

Make it possible to give externals names/util.inspect.custom #28250

Closed
emilbayes opened this issue Jun 16, 2019 · 4 comments
Closed

Make it possible to give externals names/util.inspect.custom #28250

emilbayes opened this issue Jun 16, 2019 · 4 comments
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.

Comments

@emilbayes
Copy link

Is your feature request related to a problem? Please describe.

In hyperdivision/hid we use externals as handles for device opaque descriptors, however during debugging it's hard to know what exactly you are working with. I want to preserve the opaqueness of the handles, but it would be nice if I could give these externals a name.

Describe the solution you'd like

Currently externals end up here in util.inspect:

return ctx.stylize('[External]', 'special');

I don't know if this should be another API in N-API, the possibility of setting util.inspect.custom or similar.

Describe alternatives you've considered

object_wrap is another alternative, but comes with much more features and boilerplate than I need. I just want to be able to give human readable names to opaque references for debugging.

@bnoordhuis bnoordhuis added feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module. labels Jun 17, 2019
@bnoordhuis
Copy link
Member

I think an override using util.inspect.custom would be acceptable. PR welcome.

@himself65
Copy link
Member

I'm working on this now

@addaleax
Copy link
Member

I think the only practical solution here would be to print the underlying pointer value if showHidden: true is set. (I would not print the pointer value by default as that may be used in remote code execution attacks.) How does that sound?

@rosaxxny
Copy link
Contributor

Hi, I'd like to work on this.

rosaxxny added a commit to rosaxxny/node that referenced this issue Jul 23, 2020
rosaxxny added a commit to rosaxxny/node that referenced this issue Jul 31, 2020
Fixes: nodejs#28250

PR-URL: nodejs#34398
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this issue Aug 4, 2020
Fixes: #28250

PR-URL: #34398
Backport-PR-URL: #34583
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
addaleax pushed a commit that referenced this issue Sep 22, 2020
Fixes: #28250

PR-URL: #34398
Backport-PR-URL: #34583
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
addaleax pushed a commit that referenced this issue Sep 22, 2020
Fixes: #28250

PR-URL: #34398
Backport-PR-URL: #34583
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants