Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
process: runtime deprecate changing process.config
The fact that `process.config` is mutable has long made it
unreliable when it really should just work. Start the process
of deprecating the ability to change it.

Fixes: #7803
Signed-off-by: James M Snell <jasnell@gmail.com>
  • Loading branch information
jasnell committed Jan 12, 2021
commit 672a3af4dd179124aff5d71613c2152753dd6aa1
11 changes: 11 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,17 @@ Type: Documentation-only.

Prefer [`message.socket`][] over [`message.connection`][].

<a id="DEP0XXX"></a>
Comment thread
jasnell marked this conversation as resolved.
Outdated
### DEP0XXX: Changing the value of `process.config`
<!-- YAML
added: REPLACEME
Comment thread
jasnell marked this conversation as resolved.
Outdated
-->

Comment thread
jasnell marked this conversation as resolved.
The `process.config` property is intended to provide access to configuration
settings set when the Node.js binary was compiled. However, the property has
been mutable by user code making it impossible to rely on. The ability to
change the value has been deprecated and will be disabled in the future.

[Legacy URL API]: url.md#url_legacy_url_api
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
Expand Down
18 changes: 17 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,23 @@ process._exiting = false;

// process.config is serialized config.gypi
const nativeModule = internalBinding('native_module');
process.config = JSONParse(nativeModule.config);

// TODO(@jasnell): Once this has gone through one full major
// release cycle, remove the setter and update the getter to
// either return a read-only object or always return a freshly
// parsed version of nativeModule.config.
let processConfig = JSONParse(nativeModule.config);
ObjectDefineProperty(process, 'config', {
enumerable: true,
configurable: true,
get() { return processConfig; },
set: deprecate(
(value) => { processConfig = value; },
'Setting process.config is deprecated. ' +
'In the future the property will be read-only.',
'DEP0XXX')
});

require('internal/worker/js_transferable').setup();

// Bootstrappers for all threads, including worker threads and main thread
Expand Down