File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2361,6 +2361,15 @@ changes:
23612361 description: Runtime deprecation.
23622362-->
23632363
2364+ <a id="DEP0126"></a>
2365+ ### DEP0126: writing to process[Symbol.toStringTag]
2366+ <!-- YAML
2367+ changes:
2368+ - version: REPLACEME
2369+ pr-url: https://github.com/nodejs/node/pull/26715
2370+ description: Runtime deprecation.
2371+ -->
2372+
23642373Type: Runtime
23652374
23662375The `_stream_wrap` module is deprecated.
Original file line number Diff line number Diff line change @@ -279,11 +279,16 @@ function setupProcessObject() {
279279 const origProcProto = Object . getPrototypeOf ( process ) ;
280280 Object . setPrototypeOf ( origProcProto , EventEmitter . prototype ) ;
281281 EventEmitter . call ( process ) ;
282+ let toStringTag = 'process' ;
282283 Object . defineProperty ( process , Symbol . toStringTag , {
283284 enumerable : false ,
284- writable : true ,
285285 configurable : false ,
286- value : 'process'
286+ get ( ) {
287+ return toStringTag ;
288+ } ,
289+ set : deprecate ( ( value ) => toStringTag = value ,
290+ 'Setting \'process[Symbol.toStringTag]\' is deprecated' ,
291+ 'DEP0126' )
287292 } ) ;
288293 // Make process globally available to users by putting it on the global proxy
289294 Object . defineProperty ( global , 'process' , {
Original file line number Diff line number Diff line change 11// Flags: --experimental-modules
22import '../common' ;
3+ import { expectWarning } from '../common/index.mjs' ;
34import assert from 'assert' ;
45import process from 'process' ;
56
67assert . strictEqual ( Object . prototype . toString . call ( process ) , '[object process]' ) ;
7- assert ( Object . getOwnPropertyDescriptor ( process , Symbol . toStringTag ) . writable ) ;
8+ process [ Symbol . toStringTag ] = 'custom process' ;
9+ expectWarning ( 'DeprecationWarning' ,
10+ 'Setting \'process[Symbol.toStringTag]\' is deprecated' ,
11+ 'DEP0126' ) ;
12+ assert . strictEqual ( Object . prototype . toString . call ( process ) ,
13+ '[object custom process]' ) ;
You can’t perform that action at this time.
0 commit comments