-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: runtime deprecated access to process.binding('util') #37787
lib: runtime deprecated access to process.binding('util') #37787
Conversation
The various `isType()` functions exposed by process.binding('util') are already available via `util.types`, and the rest really aren't safe for external use. Deprecate access with the intent of removing access in the near future. Signed-off-by: James M Snell <jasnell@gmail.com>
Thanks for the ping. Is this just when accessing util via |
Yes, it's only triggered when accessing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soooo... I don't want to reiterate the exact same conversation we had in #37485, but I would stick to my original suggestion, which would be to not runtime-deprecate it and instead make it so that process.binding('util')
returns { ...require('util').types }
(or the currently available subset, if we're picky and are okay with a few more lines in our code), and just leave it like that forever. Is there anything speaking against that? The code required to implement that should be fairly trivial.
I guess the bit I'm struggling with is why we would do that. Even with that said, a runtime deprecation of the current exports is still appropriate given that there are other methods and constants exposed here that do not make sense to expose in any scenario. The step after runtime deprecation does not have to be removal -- the step after deprecation could be easily be replacing the current tl;dr ... we can do both. runtime deprecate the current and replace it after. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the bit I'm struggling with is why we would do that. ``
Again – not trying to rehash the entire conversation here, but the point is that there’s still a decent amount of code that does use process.binding('util')
for type checking, and whether that’s because people don’t upgrade deep dependencies is not actually relevant here. (Just like there is a decent amount of code that still uses atob
and btoa
, by the way… and we have just introduced those because of that!)
So: The reason why we do that is that we care about our users, which involves caring about backwards compatibility and making transitions between Node.js versions as smoothly as possible when it comes at trivial cost to us.
I do realize that it’s frustrating when somebody is objecting without putting in the work to provide an alternative, so: #37819
Could we perhaps do both? it'd be two semver-majors, ofc, but at least then we can get there. |
I'm not going to worry about this. @addaleax's alternative PR is fine. |
Ref: #37485 (review) Ref: #37787 PR-URL: #37819 Refs: #37787 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
The various
isType()
functions exposed by process.binding('util')are already available via
util.types
, and the rest really aren'tsafe for external use. Deprecate access with the intent of removing
access in the near future.
/cc @ljharb since I know lodash still references this for Node.js version < 10 (for those users still on < 10.x this deprecation message will never print anyway).
and @addaleax whom I know has opinions on this stuff ;-)
Signed-off-by: James M Snell jasnell@gmail.com