Skip to content

Provide mechanism for autopopulating node.js process.env#3311

Merged
jasnell merged 1 commit intomainfrom
jasnell/workerd-autopopulate-process-env
Feb 25, 2025
Merged

Provide mechanism for autopopulating node.js process.env#3311
jasnell merged 1 commit intomainfrom
jasnell/workerd-autopopulate-process-env

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Jan 9, 2025

Autopopulates the process.env from bindings in local dev. A similar PR will be needed internally to enable it there as it won't be automatic.

See caveats: #3311 (comment)

@jasnell jasnell requested review from a team as code owners January 9, 2025 17:01
@jasnell jasnell requested a review from a team January 9, 2025 17:01
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch 3 times, most recently from 122a5b8 to d08499e Compare January 9, 2025 21:36
Comment thread src/workerd/server/workerd-api.c++ Outdated
Comment thread src/node/internal/util.d.ts Outdated
Comment thread src/workerd/api/node/util.h
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch 2 times, most recently from 00c74b2 to f6f3f64 Compare January 10, 2025 15:12
@jasnell jasnell requested a review from anonrig January 10, 2025 15:15
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch from f6f3f64 to 7f531ca Compare January 10, 2025 15:15
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch from 7f531ca to 5356dc7 Compare January 10, 2025 15:54
Comment thread src/workerd/api/node/util.h Outdated
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch from e6519ab to 09a9009 Compare January 10, 2025 16:28
vicb
vicb previously requested changes Jan 10, 2025
Copy link
Copy Markdown
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

@irvinebroque can we discuss this?

I oppose this change of it exposed secrets to the world via process.env

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Jan 10, 2025

I oppose this change of it exposed secrets to the world via process.ENV

To be clear... the change puts any TEXT binding on process.env. We have no way of knowing if a a TEXT binding contains something that is considered a secret or not. If tooling insists on adding secrets to the worker configuration using a TEXT binding then this would mean we just cannot populate process.env automatically at all right now because we have zero ability to differentiate if the value of the TEXT binding is secret or not.

Comment thread src/workerd/io/compatibility-date.capnp Outdated
Comment thread src/workerd/api/node/tests/process-nodejs-test.js
Comment thread src/workerd/jsg/setup.h Outdated
Comment thread src/workerd/api/node/tests/process-nodejs-test.js
Comment thread src/workerd/server/workerd-api.c++
Comment thread src/workerd/api/node/util.c++
Comment thread src/workerd/io/compatibility-date.capnp Outdated
Comment thread src/workerd/jsg/setup.h
@jasnell jasnell enabled auto-merge (squash) January 14, 2025 16:04
@jasnell jasnell disabled auto-merge January 14, 2025 18:21
@jasnell jasnell marked this pull request as draft January 14, 2025 18:21
@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Jan 14, 2025

Moved back to draft due to continued backend discussion on how the implementation intersects with non-nodejs-compat related aspects of the runtime.

Signed-off-by: James M Snell <jsnell@cloudflare.com>
@jasnell jasnell force-pushed the jasnell/workerd-autopopulate-process-env branch from 590cb18 to a36ee3c Compare February 25, 2025 20:32
@jasnell jasnell marked this pull request as ready for review February 25, 2025 20:32
@jasnell jasnell dismissed vicb’s stale review February 25, 2025 20:32

Objection is noted but decision has been made to move forward.

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Feb 25, 2025

Rebased the PR and expanded comments. Maintained the existing implementation approach. If it becomes necessary it ought to be able to further change the underlying implementation details without breaking changes. The hypothetical case around how to handle potential new binding types that evaluate to strings can be addressed separately later when they are no longer hypothetical. An internal PR is necessary.

Copy link
Copy Markdown
Collaborator

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

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

👍 let's find a way to ship

@jasnell jasnell dismissed kentonv’s stale review February 25, 2025 20:45

Current approach meets the immediate need. Hypothetical additional cases can be looked at separately later.

@vicb
Copy link
Copy Markdown
Contributor

vicb commented Feb 25, 2025

Could a doc PR be prepared for this change?

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Feb 25, 2025

There already is a doc PR cloudflare/cloudflare-docs#19187

@jasnell jasnell merged commit ebfedb9 into main Feb 25, 2025
@jasnell jasnell deleted the jasnell/workerd-autopopulate-process-env branch February 25, 2025 22:17
@vicb
Copy link
Copy Markdown
Contributor

vicb commented Feb 26, 2025

What are the plans regarding:

Autopopulates the process.env from bindings in local dev. A similar PR will be needed internally to enable it there as it won't be automatic.

When this will be activated on EW? When can this be enabled?

Does wrangler needs to be updated to support the flag/CLI options, is there a tracking issue?

gabivlj pushed a commit to gabivlj/workerd that referenced this pull request Jun 18, 2025
Co-authored-by: Alex Robinson <arobinson@cloudflare.com>
jasnell added a commit to jasnell/cloudflare-docs that referenced this pull request Jul 31, 2025
jasnell added a commit to jasnell/cloudflare-docs that referenced this pull request Aug 12, 2025
jasnell added a commit to cloudflare/cloudflare-docs that referenced this pull request Aug 12, 2025
thomasgauvin pushed a commit to cloudflare/cloudflare-docs that referenced this pull request Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants