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

Remove default throw behavior in astro:env #12480

Merged
merged 5 commits into from
Nov 20, 2024
Merged

Remove default throw behavior in astro:env #12480

merged 5 commits into from
Nov 20, 2024

Conversation

matthewp
Copy link
Contributor

Changes

  • Removes the default throw for getEnv.
  • Plan is to move away from having astro:env be dependent on timing; if some code runs before setGetEnv has been called it currently could result in incorrect or missing environment variables.
  • Instead now we always default to the process.env[key] approach. Since this is what most adapters need anyways, we don't have to worry about bundling causing issues of code executing in unwanted order.
  • Now only Cloudflare needs to ensure it calls setGetEnv, and it already has the constraint of not allowing vars to be grabbed at the top level.

Testing

  • manual

Docs

N/A, bug fix

Copy link

changeset-bot bot commented Nov 19, 2024

🦋 Changeset detected

Latest commit: 2ae06b1

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 the pkg: astro Related to the core `astro` package (scope) label Nov 19, 2024
Copy link

codspeed-hq bot commented Nov 19, 2024

CodSpeed Performance Report

Merging #12480 will not alter performance

Comparing env-no-throw (2ae06b1) with main (46f6b38)

Summary

✅ 6 untouched benchmarks

@florian-lefebvre
Copy link
Member

More stuff can be removed:

@matthewp
Copy link
Contributor Author

@florian-lefebvre made the changes you suggested. We're still doing validation though, @ematipico is going to work on another approach that doesn't rely on setGetEnv.

@ematipico ematipico merged commit c3b7e7c into main Nov 20, 2024
5 checks passed
@ematipico ematipico deleted the env-no-throw branch November 20, 2024 11:09
This was referenced Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants