-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
process: wrap process.binding for selective fallthrough to internalBinding #22269
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,6 +318,24 @@ | |
for (var i = 0; i < arguments.length; i++) | ||
this.push(arguments[i]); | ||
} | ||
|
||
// Deprecated specific process.binding() modules, but not all, allow | ||
// selective fallback to internalBinding for the deprecated ones. | ||
const processBinding = process.binding; | ||
const internalBindingWhitelist = new Set(['uv']); | ||
const internalBindingWarned = new Set(); | ||
process.binding = function binding(name) { | ||
if (internalBindingWhitelist.has(name)) { | ||
if (!internalBindingWarned.has(name)) { | ||
process.emitWarning( | ||
`Use of process.binding('${name}') is deprecated.`, | ||
'DeprecationWarning', 'DEP0111'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add docs in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also it should be DEP00XX There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the existing DEP0111 process.binding deprecation. The documentation is already there. The odd but is that it's not a complete switch to a runtime deprecation. |
||
internalBindingWarned.add(name); | ||
} | ||
return internalBinding(name); | ||
} | ||
return processBinding(name); | ||
}; | ||
} | ||
|
||
function setupGlobalVariables() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Flags: --no-warnings | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
common.expectWarning( | ||
'DeprecationWarning', | ||
'Use of process.binding(\'uv\') is deprecated.', | ||
'DEP0111' | ||
); | ||
|
||
assert(process.binding('uv')); |
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.
please use SafeSet
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.
Done