-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: mark process.env as side-effect-free
Read-only access to `process.env` does not have side effects. Refs: #27523 PR-URL: #27684 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Aleksei Koziatinskii <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]>
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
// Test that read-only process.env access is considered to have no | ||
// side-effects by the inspector. | ||
|
||
const assert = require('assert'); | ||
const inspector = require('inspector'); | ||
|
||
const session = new inspector.Session(); | ||
session.connect(); | ||
|
||
process.env.TESTVAR = 'foobar'; | ||
|
||
session.post('Runtime.evaluate', { | ||
expression: 'process.env.TESTVAR', | ||
throwOnSideEffect: true | ||
}, (error, res) => { | ||
assert.ifError(error); | ||
assert.deepStrictEqual(res, { | ||
result: { type: 'string', value: 'foobar' } | ||
}); | ||
}); |