@@ -46,10 +46,8 @@ const {
46
46
JSONParse,
47
47
ObjectDefineProperty,
48
48
ObjectGetPrototypeOf,
49
- ObjectPreventExtensions,
50
49
ObjectSetPrototypeOf,
51
- ReflectGet,
52
- ReflectSet,
50
+ ObjectFreeze,
53
51
SymbolToStringTag,
54
52
globalThis,
55
53
} = primordials ;
@@ -91,75 +89,18 @@ process._exiting = false;
91
89
// process.config is serialized config.gypi
92
90
const nativeModule = internalBinding ( 'builtins' ) ;
93
91
94
- // TODO(@jasnell): Once this has gone through one full major
95
- // release cycle, remove the Proxy and setter and update the
96
- // getter to either return a read-only object or always return
97
- // a freshly parsed version of nativeModule.config.
98
-
99
- const deprecationHandler = {
100
- warned : false ,
101
- message : 'Setting process.config is deprecated. ' +
102
- 'In the future the property will be read-only.' ,
103
- code : 'DEP0150' ,
104
- maybeWarn ( ) {
105
- if ( ! this . warned ) {
106
- process . emitWarning ( this . message , {
107
- type : 'DeprecationWarning' ,
108
- code : this . code
109
- } ) ;
110
- this . warned = true ;
111
- }
112
- } ,
113
-
114
- defineProperty ( target , key , descriptor ) {
115
- this . maybeWarn ( ) ;
116
- return ObjectDefineProperty ( target , key , descriptor ) ;
117
- } ,
118
-
119
- deleteProperty ( target , key ) {
120
- this . maybeWarn ( ) ;
121
- delete target [ key ] ;
122
- } ,
123
-
124
- preventExtensions ( target ) {
125
- this . maybeWarn ( ) ;
126
- return ObjectPreventExtensions ( target ) ;
127
- } ,
128
-
129
- set ( target , key , value ) {
130
- this . maybeWarn ( ) ;
131
- return ReflectSet ( target , key , value ) ;
132
- } ,
133
-
134
- get ( target , key , receiver ) {
135
- const val = ReflectGet ( target , key , receiver ) ;
136
- if ( val != null && typeof val === 'object' ) {
137
- // eslint-disable-next-line node-core/prefer-primordials
138
- return new Proxy ( val , deprecationHandler ) ;
139
- }
140
- return val ;
141
- } ,
142
-
143
- setPrototypeOf ( target , proto ) {
144
- this . maybeWarn ( ) ;
145
- return ObjectSetPrototypeOf ( target , proto ) ;
146
- }
147
- } ;
148
-
149
- // eslint-disable-next-line node-core/prefer-primordials
150
- let processConfig = new Proxy (
151
- JSONParse ( nativeModule . config ) ,
152
- deprecationHandler ) ;
92
+ const processConfig = JSONParse ( nativeModule . config , ( _key , value ) => {
93
+ // The `reviver` argument of the JSONParse method will visit all the values of
94
+ // the parsed config, including the "root" object, so there is no need to
95
+ // explicitly freeze the config outside of this method
96
+ return ObjectFreeze ( value ) ;
97
+ } ) ;
153
98
154
99
ObjectDefineProperty ( process , 'config' , {
155
100
__proto__ : null ,
156
101
enumerable : true ,
157
102
configurable : true ,
158
- get ( ) { return processConfig ; } ,
159
- set ( value ) {
160
- deprecationHandler . maybeWarn ( ) ;
161
- processConfig = value ;
162
- }
103
+ value : processConfig ,
163
104
} ) ;
164
105
165
106
require ( 'internal/worker/js_transferable' ) . setup ( ) ;
0 commit comments