Moritz Raho
175b78bc02
src: fix typo in process.env accessor error message
...
PR-URL: https://github.com/nodejs/node/pull/47014
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-07-07 00:06:06 +03:00
legendecas
fcfde3412e
src: rename internal module declaration as internal bindings
...
This is a continuation of the name reification on the internal bindings.
Renames NODE_MODULE_CONTEXT_AWARE_INTERNAL and
NODE_MODULE_EXTERNAL_REFERENCE to NODE_BINDING_CONTEXT_AWARE_INTERNAL
and NODE_BINDING_EXTERNAL_REFERENCE respectively.
PR-URL: https://github.com/nodejs/node/pull/45551
Backport-PR-URL: https://github.com/nodejs/node/pull/46336
Refs: https://github.com/nodejs/node/issues/44036
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2023-01-31 08:04:22 -05:00
Ben Noordhuis
b88ee545f2
src: make structuredClone work for process.env
...
Fixes: https://github.com/nodejs/node/issues/45380
PR-URL: https://github.com/nodejs/node/pull/45698
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2023-01-03 08:39:15 -05:00
Himself65
e6a7300a10
process: disallow some uses of Object.defineProperty() on process.env
...
Disallow the use of Object.defineProperty() to hide entries in
process.env or make them immutable.
PR-URL: https://github.com/nodejs/node/pull/28006
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-04-04 09:24:17 +01:00
Darshan Sen
fa7cdd6fc9
src: use SPrintF in ProcessEmitWarning
...
PR-URL: https://github.com/nodejs/node/pull/38758
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-05-25 07:16:42 -07:00
James M Snell
16cb4f720b
lib: support setting process.env.TZ on windows
...
Fixes: https://github.com/nodejs/node/issues/4230
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/38642
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-05-17 12:02:49 -07:00
raisinten
5a637e9d36
src: remove empty name check in node_env_var.cc
...
The empty name check has been removed since this has landed:
https://github.com/libuv/libuv/pull/2473
PR-URL: https://github.com/nodejs/node/pull/36133
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-15 15:53:37 +00:00
raisinten
091f0d1a9e
src: refactor using-declarations node_env_var.cc
...
PR-URL: https://github.com/nodejs/node/pull/36128
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-19 05:43:44 +01:00
Joyee Cheung
7a447bcd54
src: snapshot node
...
This runs `lib/internal/bootstrap/node.js` before creating
the builtin snapshot and deserialize the loaders from the
snapshot in deserialization mode.
PR-URL: https://github.com/nodejs/node/pull/32984
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
2020-07-18 11:23:21 +08:00
Anna Henningsen
a038199265
src,doc,test: remove String::New default parameter
...
`kNormal` has been the implicit default for a while now (since V8 7.6).
Refs: https://github.com/v8/v8/commit/e0d7f816990ada28ebe1281ca9431236ef8c6e4f
PR-URL: https://github.com/nodejs/node/pull/34248
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-07-14 15:13:34 +02:00
Joyee Cheung and Anna Henningsen
86fdaa7455
src: retrieve binding data from the context
...
Instead of passing them through the data bound to function
templates, store references to them in a list embedded inside
the context.
This makes the function templates more context-independent,
and makes it possible to embed binding data in non-main contexts.
Co-authored-by: Anna Henningsen <anna@addaleax.net >
PR-URL: https://github.com/nodejs/node/pull/33139
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2020-05-06 06:44:04 +02:00
Christopher Beeson
20e0cc0592
src: do not compare against wide characters
...
PR-URL: https://github.com/nodejs/node/pull/32921
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-04-27 19:31:11 +02:00
Christopher Beeson
3ccdf8ad22
src: fix empty-named env var assertion failure
...
Setting an environment variable with an empty name on Windows resulted
in an assertion failure, because it was checked for an '=' sign at the
beginning without verifying the length was greater than 0.
Fixes: https://github.com/nodejs/node/issues/32920
Refs: https://github.com/nodejs/node/pull/27310
PR-URL: https://github.com/nodejs/node/pull/32921
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-04-27 19:31:09 +02:00
Christopher Beeson
540f2785dd
worker: fix process.env var empty key access
...
PR-URL: https://github.com/nodejs/node/pull/32921
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-04-27 19:31:06 +02:00
himself65
2d8812984f
src: remove unnecessary 'Local.As' operation
...
PR-URL: https://github.com/nodejs/node/pull/32286
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-30 17:12:31 +02:00
Joyee Cheung
a8772da54d
src: refactor debug category parsing
...
Move the debug category parsing into a new EnabledDebugList class,
so that it can be reused outside of Environment.
PR-URL: https://github.com/nodejs/node/pull/31884
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-03-10 05:52:38 +08:00
Denys Otrishko
cee145251e
src: improve KVStore API
...
This adds `const char*` based APIs to KVStore to avoid multiple string
conversions (char -> Utf8 -> Local -> char etc.) when possible.
PR-URL: https://github.com/nodejs/node/pull/31773
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-09 13:08:14 +01:00
Harshitha KP
4614f64aeb
src: suppress warning in src/node_env_var.cc
...
Initialise the superclass object in the copy constructor of mapKVStore
PR-URL: https://github.com/nodejs/node/pull/31136
Refs: https://github.com/nodejs/node/issues/18983
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-01-02 15:17:27 -08:00
Anna Henningsen
850f38125c
src: enhance feature access CHECKs during bootstrap
...
This adds `CHECK`s verifying that bootstrapping has finished
before environment variables are accessed or handles/requests
are created. The latter complements a pair of existent checks,
but fails earlier and thus gives information about the call
site, effectively addressing the TODO comment there.
PR-URL: https://github.com/nodejs/node/pull/30452
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-11-18 06:16:25 +01:00
Anna Henningsen
6072e01c93
src: do not use std::function for OnScopeLeave
...
Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.
PR-URL: https://github.com/nodejs/node/pull/30134
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-11-07 10:39:40 +01:00
Anna Henningsen
5664791790
src: use libuv to get env vars
...
This allows us to remove OS-dependent code.
confidence improvement accuracy (*) (**) (***)
process/bench-env.js operation='delete' n=1000000 3.57 % ±10.86% ±14.46% ±18.85%
process/bench-env.js operation='enumerate' n=1000000 *** -14.06 % ±7.46% ±9.94% ±12.96%
process/bench-env.js operation='get' n=1000000 -7.97 % ±11.80% ±15.70% ±20.45%
process/bench-env.js operation='query' n=1000000 -1.32 % ±8.38% ±11.17% ±14.58%
process/bench-env.js operation='set' n=1000000 -0.98 % ±9.63% ±12.81% ±16.68%
The drop in enumeration performance is likely due to the large
number of extra allocations that libuv performs. However, enumerating
process.env should generally not be a hot path in most applications.
PR-URL: https://github.com/nodejs/node/pull/29188
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-09-18 23:24:46 +02:00
Devendra Satram
b354d12599
src: modified RealEnvStore methods to use libuv functions
...
Modified RealEnvStore::Get, Set, Query and Delete methods
to use libuv methods environment variables operations instead
of using os specific logic and switches.
Fixes: https://github.com/nodejs/node/issues/27211
Refs: http://docs.libuv.org/en/v1.x/misc.html
PR-URL: https://github.com/nodejs/node/pull/27310
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2019-09-12 19:11:33 +02:00
Ben Noordhuis
eba348b6ae
src: make process.env.TZ setter clear tz cache
...
Since the presence of the libc and V8 timezone caches seem to be
a perennial source of confusion to users ("why doesn't it work?!"),
let's try to support that pattern by intercepting assignments to
the TZ environment variable and reset the caches as a side effect.
Fixes: https://github.com/nodejs/node/issues/19974
PR-URL: https://github.com/nodejs/node/pull/20026
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com >
Reviewed-By: Timothy Gu <timothygu99@gmail.com >
2019-05-23 11:34:17 +02:00
Anna Henningsen
abe82110b7
process: mark process.env as side-effect-free
...
Read-only access to `process.env` does not have side effects.
Refs: https://github.com/nodejs/node/pull/27523
PR-URL: https://github.com/nodejs/node/pull/27684
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Aleksei Koziatinskii <ak239spb@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2019-05-18 11:08:47 +08:00
Sam Roberts
b6bfc19378
src: remove util-inl.h from header files
...
Its intended that *-inl.h header files are only included into the src
files that call the inline methods. Explicitly include it into the files
that need it.
PR-URL: https://github.com/nodejs/node/pull/27631
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-05-13 13:43:26 -07:00
gengjiawen
51079db826
src: apply clang-tidy rule modernize-use-equals-default
...
PR-URL: https://github.com/nodejs/node/pull/27264
Reviewed-By: Refael Ackermann <refack@gmail.com >
2019-04-24 13:32:43 -04:00
Anna Henningsen
9fbf0c60b5
worker: use copy of process.env
...
Instead of sharing the OS-backed store for all `process.env` instances,
create a copy of `process.env` for every worker that is created.
The copies do not interact. Native-addons do not see modifications to
`process.env` from Worker threads, but child processes started from
Workers do default to the Worker’s copy of `process.env`.
This makes Workers behave like child processes as far as `process.env`
is concerned, and an option corresponding to the `child_process`
module’s `env` option is added to the constructor.
Fixes: https://github.com/nodejs/node/issues/24947
PR-URL: https://github.com/nodejs/node/pull/26544
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-03-30 22:25:35 +01:00
Anna Henningsen
1ee37aac09
src: implement generic backend for process.env
...
Allow a generic string-based backing store, with no significance
to the remainder of the process, as a store for `process.env`.
PR-URL: https://github.com/nodejs/node/pull/26544
Fixes: https://github.com/nodejs/node/issues/24947
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-03-30 22:25:34 +01:00
Anna Henningsen
f5b5fe3937
src: allow per-Environment set of env vars
...
Abstract the `process.env` backing mechanism in C++ to allow
different kinds of backing stores for `process.env` for different
Environments.
PR-URL: https://github.com/nodejs/node/pull/26544
Fixes: https://github.com/nodejs/node/issues/24947
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-03-30 22:25:33 +01:00
Anna Henningsen
955be8623d
src: use object to pass Environment to functions
...
Use a `v8::Object` with an internal field, rather than a
`v8::External`.
On a `GetReturnValue().Set(Environment::GetCurrent(args) == nullptr)`
noop function, this benchmarks as a ~60 % speedup, as calls to
`obj->GetAlignedPointerFromInternalField()` can be inlined and
the field is stored with one level of indirection less.
This also makes breaking up some pieces of the `Environment` class
into per-native-binding data easier, if we want to pursue that path
in the future.
PR-URL: https://github.com/nodejs/node/pull/26382
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-03-05 00:56:37 +01:00
Anna Henningsen
95571ac1e9
src: pass along errors from process obj instantiation
...
PR-URL: https://github.com/nodejs/node/pull/25734
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2019-01-29 20:02:01 +01:00
Benjamin
0b50972e6c
process: check env->EmitProcessEnvWarning() last
...
Calling env->EmitProcessEnvWarning() prevents additional warnings
from being set it should therefore be called only if a warning will
emit.
PR-URL: https://github.com/nodejs/node/pull/25575
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
2019-01-21 10:30:04 -08:00
Joyee Cheung
1838d00eba
src: reduce includes of node_internals.h
...
PR-URL: https://github.com/nodejs/node/pull/25507
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-01-21 07:54:42 +01:00
Joyee Cheung
7824280b58
src: declare process-related C++ methods in node_process.h
...
Instead of in node_internals.h. Also move process property
accessors that are not reused into node_process_object.cc
and make them static.
PR-URL: https://github.com/nodejs/node/pull/25397
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2019-01-11 20:11:55 +08:00
Joyee Cheung
9db9e7e541
src: move per-process global variables into node::per_process
...
So that it's easier to tell whether we are manipulating per-process
global states that may need to be treated with care to avoid races.
Also added comments about these variables and moved some of them
to a more suitable compilation unit:
- Move `v8_initialized` to `util.h` since it's only used in
`util.cc` and `node.cc`
- Rename `process_mutex` to `tty_mutex` and move it into
`node_errors.cc` since that's the only place it's used
to guard the tty.
- Move `per_process_opts_mutex` and `per_process_opts`
into `node_options.h` and rename them to
`per_process::cli_options[_mutex]`
- Rename `node_isolate[_mutex]` to `per_process::main_isolate[_mutex]`
PR-URL: https://github.com/nodejs/node/pull/25302
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-01-08 00:28:16 +01:00
Joyee Cheung
19a9205645
process: move environment variable proxy code into node_env_var.cc
...
Instead of exposing all the NamedPropertyHandlerConfiguration()
parameters in node_internals, simply expose a CreateEnvVarProxy()
method that returns a Local<Value> that implements process.env,
and mark all the property handlers static in node_env_var.cc.
This makes the code more encapsulated.
PR-URL: https://github.com/nodejs/node/pull/25067
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-12-17 16:21:25 -08:00