The short version
- Checks never throw or reject. Network failures, timeouts, a missing or wrong client key and bad responses all turn into an answer.
- A server that has already loaded your flags keeps using them.
- A check waits at most 2 seconds for the API, and only when its cache needs refreshing.
- Your app keeps running. Only dashboard changes stop arriving until Flaggish is back.
Where the answer comes from
Each check uses the first of these that has an answer:
- The config. The fresh one, or if a refresh failed, the last one the SDK fetched successfully.
- The fallback you pass to the check:
getFlag(key, ctx, fallback)orisEnabled(key, ctx, fallback). - Your defaults: the
defaultsoption. false.
useFlag(key, fallback) in React checks your defaults before its fallback, so set your values in defaults if you use both.
<FlaggishProvider defaults={{ 'new-checkout': false, 'maintenance-banner': true }}>Pick defaults that are safe: usually the old behaviour, so a new feature stays off if Flaggish can’t be reached.
Timeouts and retries
| Setting | Default | What happens |
|---|---|---|
| Request timeout | 2 seconds | A config request that takes longer is abandoned, and the check uses the fallbacks above. |
| Cache | 30 seconds | Flags are reused for 30 seconds. A failed fetch also waits 30 seconds before the next try, so an outage isn’t hammered. |
During an outage, one check every 30 seconds waits for the timeout; the checks in between answer straight away from memory. Checks that arrive while a fetch is in flight share it, so they don’t each wait separately. Change both with timeoutMs and cacheTtlMs.
The SDK logs one console warning when fetches start failing, not one per check:
[flaggish] Could not fetch flag config, using fallbacks: …What your users see
| Situation | Users get |
|---|---|
| A server that loaded flags before the outage | The same answers as before, including rollouts. They don’t notice. |
| A server that starts during the outage | Your fallbacks and defaults until Flaggish is back |
| A browser page loaded during the outage, with FlaggishServerProvider | Whatever the server had, passed down on first render |
| A browser page loaded during the outage, with FlaggishProvider alone | Your defaults, after the request times out |
| Pages already open | The answers they loaded. They don’t change. |
When Flaggish comes back, the next refresh picks up your current flags, within about 30 seconds.
Reach during an outage
Reach is best effort. If it can’t be sent, it’s dropped: it never throws, never logs, and never changes or delays a flag result.
Next.js render signals
The one thing the server helpers let through is Next.js’s own render-control signal, for example the one cookies() raises when a cacheComponents prerender ends. Next.js expects it, and uses it to render the component per request. It’s not an error. See Suspense and cacheComponents.