File tree 5 files changed +46
-2
lines changed
5 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -2233,6 +2233,21 @@ like `dns.lookup(false)` due to backward compatibility.
2233
2233
This behavior is undocumented and is thought to be unused in real world apps.
2234
2234
It will become an error in future versions of Node.js.
2235
2235
2236
+ <a id="DEP0119"></a>
2237
+ ### DEP0119: process.binding(' uv' ).errname() private API
2238
+ <!--
2239
+ changes:
2240
+ - version: REPLACEME
2241
+ pr-url: https://github.com/nodejs/node/pull/23597
2242
+ description: Documentation-only deprecation.
2243
+ -->
2244
+
2245
+ Type: Documentation-only (supports [`--pending-deprecation`][])
2246
+
2247
+ Directly calling `process.binding(' uv' ).errname(<val>)` is deprecated.
2248
+ Please make sure to use [`util.getSystemErrorName()`][] instead.
2249
+
2250
+
2236
2251
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
2237
2252
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
2238
2253
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
@@ -2300,6 +2315,7 @@ It will become an error in future versions of Node.js.
2300
2315
[`util._extend()`]: util.html#util_util_extend_target_source
2301
2316
[`util.debug()`]: util.html#util_util_debug_string
2302
2317
[`util.error()`]: util.html#util_util_error_strings
2318
+ [`util.getSystemErrorName()`]: util.html#util_util_getsystemerrorname_err
2303
2319
[`util.inspect()`]: util.html#util_util_inspect_object_options
2304
2320
[`util.inspect.custom`]: util.html#util_util_inspect_custom
2305
2321
[`util.isArray()`]: util.html#util_util_isarray_object
Original file line number Diff line number Diff line change @@ -134,6 +134,7 @@ Environment::Environment(IsolateData* isolate_data,
134
134
printed_error_(false ),
135
135
abort_on_uncaught_exception_(false ),
136
136
emit_env_nonstring_warning_(true ),
137
+ emit_err_name_warning_(true ),
137
138
makecallback_cntr_(0 ),
138
139
should_abort_on_uncaught_toggle_(isolate_, 1 ),
139
140
trace_category_state_(isolate_, kTraceCategoryCount ),
Original file line number Diff line number Diff line change @@ -843,6 +843,12 @@ class Environment {
843
843
return current_value;
844
844
}
845
845
846
+ inline bool EmitErrNameWarning () {
847
+ bool current_value = emit_err_name_warning_;
848
+ emit_err_name_warning_ = false ;
849
+ return current_value;
850
+ }
851
+
846
852
typedef void (*native_immediate_callback)(Environment* env, void * data);
847
853
// cb will be called as cb(env, data) on the next event loop iteration.
848
854
// obj will be kept alive between now and after the callback has run.
@@ -929,6 +935,7 @@ class Environment {
929
935
bool printed_error_;
930
936
bool abort_on_uncaught_exception_;
931
937
bool emit_env_nonstring_warning_;
938
+ bool emit_err_name_warning_;
932
939
size_t makecallback_cntr_;
933
940
std::vector<double > destroy_async_id_list_;
934
941
Original file line number Diff line number Diff line change @@ -39,10 +39,17 @@ using v8::String;
39
39
using v8::Value;
40
40
41
41
42
- // TODO(joyeecheung): deprecate this function in favor of
43
- // lib/util.getSystemErrorName()
44
42
void ErrName (const FunctionCallbackInfo<Value>& args) {
45
43
Environment* env = Environment::GetCurrent (args);
44
+ if (env->options ()->pending_deprecation && env->EmitErrNameWarning ()) {
45
+ if (ProcessEmitDeprecationWarning (
46
+ env,
47
+ " Directly calling process.binding('uv').errname(<val>) is being"
48
+ " deprecated. "
49
+ " Please make sure to use util.getSystemErrorName() instead." ,
50
+ " DEP0119" ).IsNothing ())
51
+ return ;
52
+ }
46
53
int err;
47
54
if (!args[0 ]->Int32Value (env->context ()).To (&err)) return ;
48
55
CHECK_LT (err, 0 );
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+
4
+ // Flags: --pending-deprecation
5
+
6
+ common . expectWarning (
7
+ 'DeprecationWarning' ,
8
+ 'Directly calling process.binding(\'uv\').errname(<val>) is being ' +
9
+ 'deprecated. Please make sure to use util.getSystemErrorName() instead.' ,
10
+ 'DEP0119'
11
+ ) ;
12
+
13
+ process . binding ( 'uv' ) . errname ( - 1 ) ;
You can’t perform that action at this time.
0 commit comments