Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upprocess: doc-only deprecate non-string env value #18990
Conversation
TimothyGu
added
the
tsc-agenda
label
Feb 25, 2018
TimothyGu
requested review from
mcollina,
targos and
nodejs/tsc
Feb 25, 2018
nodejs-github-bot
added
the
C++
label
Feb 25, 2018
TimothyGu
referenced this pull request
Feb 25, 2018
Closed
src: delete process.env values set to undefined #18158
TimothyGu
added
semver-major
process
labels
Feb 25, 2018
This comment has been minimized.
This comment has been minimized.
addaleax
reviewed
Feb 25, 2018
|
Thanks! I think this is a good approach. |
| "DEP01XX").IsNothing()) | ||
| return; | ||
| env_nonstring_deprecation_warned = true; | ||
| } |
This comment has been minimized.
This comment has been minimized.
addaleax
Feb 25, 2018
Member
Thank you for this, I would expect it to become pretty helpful when trying to figure out actual ecosystem usage.
| @@ -867,7 +871,8 @@ console.log(process.env.foo); | |||
| ``` | |||
|
|
|||
| Assigning a property on `process.env` will implicitly convert the value | |||
| to a string. | |||
| to a string. **This behavior is deprecated.** Future versions of Node.js will | |||
This comment has been minimized.
This comment has been minimized.
addaleax
Feb 25, 2018
Member
I’d replace will → may – at least I, personally, don’t feel comfortable committing to this.
| @@ -2628,6 +2633,17 @@ static void EnvGetter(Local<Name> property, | |||
| static void EnvSetter(Local<Name> property, | |||
| Local<Value> value, | |||
| const PropertyCallbackInfo<Value>& info) { | |||
| if (config_pending_deprecation && !env_nonstring_deprecation_warned && | |||
| !value->IsString()) { | |||
This comment has been minimized.
This comment has been minimized.
addaleax
Feb 25, 2018
Member
Can we also allow numbers + booleans, here and in the doc? I don’t see anything wrong with the well-defined behaviour we get from them, plus at least in the case of numbers doing this is pretty common (I count 3 test files in our suite alone).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mcollina
approved these changes
Feb 26, 2018
|
LGTM. Very good work. |
lpinca
approved these changes
Feb 26, 2018
cjihrig
approved these changes
Feb 26, 2018
jasnell
approved these changes
Feb 26, 2018
|
Few nits. Generally lgtm tho |
| @@ -914,6 +914,16 @@ Type: Runtime | |||
| This was never a documented feature. | |||
| <a id="DEP01XX"></a> | |||
| ### DEP01XX: process.env string coercion | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jasnell
Feb 27, 2018
Member
Nope, I mean DEP00XX. The same tooling that looks for REPLACEME in the docs looks for that pattern also and will flag it on release if it's not set properly
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| <a id="DEP01XX"></a> | ||
| ### DEP01XX: process.env string coercion | ||
| Type: Documentation-only (supports [`--pending-deprecation`][]) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // Set by EnvSetter when a warning is emitted for non-string assignment to | ||
| // process.env, to prevent the same warning from being emitted multiple times | ||
| // per process. | ||
| bool env_nonstring_deprecation_warned = false; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mhdawson
referenced this pull request
Feb 26, 2018
Closed
Node.js Foundation Technical Steering Committee (TSC) Meeting 2018-02-28 #496
This comment has been minimized.
This comment has been minimized.
|
Why is this marked tsc-agenda? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Removing tsc-agenda from here as well. We can leave this to github, there seems an agreement that this is a less contentious way to fix the problem. |
mcollina
added
tsc-review
and removed
tsc-agenda
labels
Feb 27, 2018
gibfahn
referenced this pull request
Feb 27, 2018
Open
Check DEP00XX and REPLACEME tags for PRs #193
TimothyGu
force-pushed the
TimothyGu:doc-deprecate-process-env-non-string
branch
2 times, most recently
from
6fbae02
to
1b49210
Mar 4, 2018
This comment has been minimized.
This comment has been minimized.
TimothyGu
force-pushed the
TimothyGu:doc-deprecate-process-env-non-string
branch
from
1b49210
to
dce66fe
Mar 4, 2018
TimothyGu
force-pushed the
TimothyGu:doc-deprecate-process-env-non-string
branch
from
dce66fe
to
e7af63b
Mar 4, 2018
This comment has been minimized.
This comment has been minimized.
addaleax
approved these changes
Mar 4, 2018
gibfahn
approved these changes
Mar 5, 2018
targos
approved these changes
Mar 5, 2018
Trott
added
the
notable-change
label
Mar 5, 2018
TimothyGu
added
author ready
and removed
tsc-review
labels
Mar 6, 2018
This comment has been minimized.
This comment has been minimized.
|
I plan on landing this this week, either tomorrow or on Wednesday. Untagging tsc-review as many TSC members have already looked at this. (I'll fix the deprecations.md merge conflict during landing.) |
thefourtheye
approved these changes
Mar 6, 2018
| !value->IsString() && !value->IsNumber() && !value->IsBoolean()) { | ||
| if (ProcessEmitDeprecationWarning( | ||
| env, | ||
| "Assigning any value other than a string, number, or boolean value " |
This comment has been minimized.
This comment has been minimized.
thefourtheye
Mar 6, 2018
Contributor
Nit: I am not a native English speaker, but I believe this message can be presented better. Unfortunately, I am also not sure how to improve it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
thefourtheye
Mar 7, 2018
Contributor
Thanks. That felt redundant to me, when I read that for the first time.
Also, does it sound better if we change the second part to, "If the value is not one of them, use the string representation of it."?
This comment has been minimized.
This comment has been minimized.
|
Landed in 5826fe4. |
TimothyGu commentedFeb 25, 2018
This PR provides an alternative approach to #18158 by deprecating the problematic behavior of
process.envwhen a non-string is assigned to a property. I would like this deprecation to become Runtime in Node.js v11.Refs: #15089
Refs: #18158
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
process