-
Notifications
You must be signed in to change notification settings - Fork 55
[GrowthBook provider] Auto refresh flags with a stale-while-revalidate strategy #148
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
|
@jdorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
AAorris
left a comment
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.
Sorry for the delay here! It looks good to me.
Could you add a changeset pnpm changeset before merging?
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Changes
Currently in the GrowthBook adapter, flags are fetched once at server startup, stored in-memory, and never refreshed.
This PR changes it so that every time a flag is evaluated, we refresh in the background from either Edge Config or the GrowthBook API (depending on which one the adapter is configured to use).
New adapter options / methods
There is a new adapater method
refresh()that can be called manually.Testing
I tested in a new Next.js app with and without Edge Config and verified that features refreshed without requiring an app restart. Also verified that when not using Edge Config, an in-memory cache is used to throttle network requests.
Because of the stale-while-revalidate logic for both Edge Config and GrowthBook's built-in fetching, it may take an extra refresh for changes to be picked up.