You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 30, 2025. It is now read-only.
We currently use HappyKit in a Next project with the following setup:
"@happykit/flags": "^3.3.0",
..."next": "13.5.2",
This project uses a standalone next build running in a docker container. We deploy this same image to multiple tenant envs, using env vars to control things like tenant_id and api keys. Internally, we leverage Next's public runtime config to propagate unique env vars instead of NEXT_PUBLIC... method of baking values into images.
const{ publicRuntimeConfig }=getConfig()as{publicRuntimeConfig: {_MY_PUBLIC_TENANT_ID: string;_MY_PUBLIC_HAPPY_KIT_FLAGS_PUBLIC_KEY: string;};};constFeatureFlagContext=createContext<AppFlags|null>(null);exportconstFeatureFlagContextProvider=({ children }: PropsWithChildren)=>{constuseFlags=createUseFlags<AppFlags>({envKey: publicRuntimeConfig._MY_PUBLIC_HAPPY_KIT_FLAGS_PUBLIC_KEY,defaultFlags: DEFAULT_FLAGS,}asConfiguration<AppFlags>);const{ flags, error }=useFlags({user: publicRuntimeConfig._MY_PUBLIC_TENANT_ID
? {key: publicRuntimeConfig._MY_PUBLIC_TENANT_ID,}
: undefined,});if(error){console.error("Failed to use flags, falling back to defaults. Error: ",error,);}return(<FeatureFlagContext.Providervalue={flags ?? DEFAULT_FLAGS}>{children}</FeatureFlagContext.Provider>);};
This setup has worked for us for a while now.
We're now attempting an upgrade from Next 13.5.2 to Next 13.5.6 - the only change in our app like so:
- "next": "13.5.2",+ "next": "13.5.6",
After this upgrade, everything is working as expected in a dev environment. However our production standalone and dockerized builds are failing to resolve flags. Debugging the issue in such a production build, I can see
the Provider component is stuck in an infinite re-render loop
the publicRuntimeConfig behavior has not changed, and is not triggering the re-renders
viewing the network requests to happykit, I can see the requests are going out with the correct payload but the requests are immediately cancelled