-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(macros): smarter .env
loading, caching, and invalidation
#4053
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
Conversation
43cb27a
to
b3f4186
Compare
b3f4186
to
7e69f23
Compare
Awesome, thanks a lot for giving this a try as well! The more solutions we have to a problem, the merrier (ignoring the new problem of choosing the right one... 😂). I've skimmed through the changes, and they look quite good to me. I really like the addition of a new Clippy lint for I'll try giving this PR a spin in a production codebase once I'm back at work, and get back with the results 👍 |
Yep, looks good to me on the surface! Haven't had a chance to test it out for real yet, but it looks like it should work fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm this works well for my use case! 🎉
For what it's worth, I approve this.
b6d2de7
to
7cbaca0
Compare
f862910
to
93b553f
Compare
Having looked over both #4018 and #4039, neither seemed like a complete solution on its own. Rather than choose which one to bless and still need to have a tedious back and-forth to arrive at a satisfactory solution, I decided to try my hand at it myself.
The major thing both PRs were missing was a way to invalidate the loaded
.env
andsqlx.toml
files after caching, since otherwise the user would need to completely reload RustAnalyzer if they made any changes to either. This necessitated the creation of a wrapper that could watch a set of files and automatically invalidate the cached value if the modified-time on any of them changed.I also felt that #4018 was just too complex in general while in #4039 I wasn't really comfortable with caching the full contents of the
.env
file since that could conceivably contain various secrets that we shouldn't be storing, even temporarily.cc and thanks to both @AlexTMjugador (#4018) and @Diggsey (#4039) for their proposed solutions. I'll be sure to credit your contributions in the changelog. It would be a great help if you both could look this over and let me know if it correctly fixes the issues you've raised. I'd also love your help figuring out how to create a regression test for this since we clearly don't test
.env
loading well enough in CI.Does your PR solve an issue?
closes #4018 (superceded PR)
closes #4039 (superceded PR)
Is this a breaking change?
Only with respect to currently unreleased changes.