-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Version
v20.4.0
Platform
Linux executive 6.2.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 17:05:07 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
process.env
What steps will reproduce the bug?
Assign undefined to any value on process.env, for example process.env.foo = undefined.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
Since values assigned to entries in process.env are always casted to string and it's not possible to have any of them set to the undefined value, then it should be fully removed from the process.env object, allowing this way to get the entry unset.
What do you see instead?
I get the entry assigned the string undefined as value.
Additional information
The same happens with null, that gets assigned with the null string, so it's not possible to differenciate when setting it to null or the string "null". In this case I'm not sure of what should be the correct behaviour, since it's similar to what happens in SQL... Maybe setting the environment variable to an empty string?
For reference, assigning an object gets serialized as [object Object], that sort of makes sense,