Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit environment variables deemed safe by default #36

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

jspahrsummers
Copy link
Member

@jspahrsummers jspahrsummers commented Nov 5, 2024

Will need to make the same changes in the Python SDK, but let's review this for correctness first.

To do

After merging

* Environment variables to inherit by default, if an environment is not explicitly given.
*/
export const DEFAULT_INHERITED_ENV_VARS =
process.platform === "win32"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these are unnecessary, I'd nuke:

ALLUSERSPROFILE, NUMBER_OF_PROCESSORS, OS, PATHEXT, TMP, WINDIR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will definitely defer to you, but here was my reasoning:

  • NUMBER_OF_PROCESSORS: Maybe needed to set reasonable concurrency defaults (e.g., for thread pools)?
  • OS: Maybe needed for compatibility checks?
  • TMP: Seemed like the same thing as TEMP, maybe applications incorrectly use one or the other

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS is basically a legacy constant, it's always Windows_NT, and TMP is also like, a legacy env var that shouldn't exist. NUMBER_OF_PROCESSORS you can probably keep but usually people use a platform API like os.cpus().length on node

this._serverParams.env === undefined
? {}
: { ...this._serverParams.env },
env: this._serverParams.env ?? getDefaultEnvironment(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to merge this? something like:

env: { ...this._serverParams.env, ...getDefaultEnvironment() }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because then there's no way to clobber the default environment. Even if we flipped the order, it'd be very annoying to unset the default keys.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure it's easy enough for callers to build their env on getDefaultEnvironment() if they want to.

@jspahrsummers jspahrsummers merged commit 844d69d into main Nov 5, 2024
4 checks passed
@jspahrsummers jspahrsummers deleted the justin/env-var-inheritance branch November 5, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants