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

fix(next): do not override process.env #12125

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre commented Oct 4, 2024

Changes

  • Fixes a bug that prevents env from being refreshed because of astro:env (we currently override process.env)
  • It's breaking for adapters, hence it's a major change against next

Testing

Should still pass. I'll make a preview release to test adapters

Docs

Changeset, will do docs later

Copy link

changeset-bot bot commented Oct 4, 2024

🦋 Changeset detected

Latest commit: 0bb259d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release labels Oct 4, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a major changeset. A reviewer will merge this at the next release if approved.

@bluwy
Copy link
Member

bluwy commented Oct 5, 2024

Linking back to a Vite issue that also describes this problem that has recent activity: vitejs/vite#17689

@bluwy
Copy link
Member

bluwy commented Oct 7, 2024

I just realized something, why does Cloudflare sets the env to process.env.* in dev? Shouldn't astro:env only handle reading from the current running nodejs astro dev or build process.env.*, and the .env files? Does Cloudflare also polyfills process.env.* in the prod runtime?

(Talking about cloudflare since it seems to be the only integration that causes us to need to expose an API)

@florian-lefebvre
Copy link
Member Author

That's because cloudflare env is loaded using wrangler platform proxy, it does not come from process env. We still need to call loadEnv() to load stuff from .env

@bluwy
Copy link
Member

bluwy commented Oct 7, 2024

But why does the cloudflare platform proxy interfere with astro:env or process.env.*? Is that something cloudflare also does during build time or during prod runtime?

Anyways, if cloudflare wants to emulate process.env.* from the platform proxy for some reason, then I think rightfully they can simply assign to process.env.*. loadEnv() within Astro would take that in account anyways, so maybe we don't need to expose another API.

@florian-lefebvre
Copy link
Member Author

There's a good reason for that! That's because an adapter can't set getEnv() in dev/build. But yeah I guess cloudflare may still be able to override process.env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: major Change triggers a `major` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants