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(cloudflare): expose env from module context #1147

Merged
merged 2 commits into from
Apr 16, 2023
Merged

fix(cloudflare): expose env from module context #1147

merged 2 commits into from
Apr 16, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Apr 16, 2023

πŸ”— Linked issue

Related #1132, #272

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Cloudflare's module format only allowed accessing env bindings within the request accessible via event.context.cloudflare.env.

This makes it harder to make existing stateless utils such as useStorage and useRuntimeConfig work with this new format.

We might make it more restricted in the feature of how/where these composables are going to be used to properly address such limitations.

Workaround with this PR assumes env is safe to be shared across requests for only internal usage and exposing it as __env__ global to be platform agnostic. User land use cases should never reply on this env.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Apr 16, 2023

Codecov Report

Merging #1147 (71011a0) into main (4108efd) will decrease coverage by 0.14%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
- Coverage   67.77%   67.63%   -0.14%     
==========================================
  Files          66       66              
  Lines        6486     6486              
  Branches      718      717       -1     
==========================================
- Hits         4396     4387       -9     
- Misses       2075     2082       +7     
- Partials       15       17       +2     

see 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0 pi0 marked this pull request as ready for review April 16, 2023 12:58
@pi0 pi0 merged commit 1cf01bf into main Apr 16, 2023
@pi0 pi0 deleted the fix/cf-global branch April 16, 2023 12:58
@pi0 pi0 mentioned this pull request Apr 28, 2023
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.

1 participant