Skip to content
Latchkey

Unleash client "not ready" / synchronized flapping in CI

The Unleash client fetches toggles asynchronously and emits a "ready" (or "synchronized") event once the first fetch completes. Code that calls isEnabled before that event runs against an empty repository, so every toggle returns its fallback. In CI this shows as tests that pass locally but flap when evaluation races the fetch.

What this error means

Toggles all evaluate to their default value in CI, then behave correctly on a re-run. There is no error; the client simply had not synchronized when the first evaluation ran.

Unleash
// isEnabled called before the client is ready:
unleash.isEnabled('new-feature'); // -> false (fallback), repository not yet synchronized

Common causes

Evaluation runs before the first fetch completes

isEnabled is called synchronously at start-up, before the client has downloaded any toggles, so it returns the fallback.

The process exits before synchronization

A short-lived CI script finishes before the client emits "synchronized", so toggles never load in time.

How to fix it

Await the ready or synchronized event

Wait for the client to signal readiness before evaluating any toggle.

unleash.js
await new Promise((resolve) => unleash.on('synchronized', resolve));
const on = unleash.isEnabled('new-feature');

Bootstrap toggles for deterministic tests

Supply a bootstrap payload so evaluations are correct immediately, without depending on the timing of the first fetch.

unleash.js
const unleash = initialize({
  url: 'http://unleash:4242/api/',
  appName: 'ci',
  bootstrap: { data: require('./unleash-bootstrap.json') },
});

How to prevent it

  • Wait for the "ready" or "synchronized" event before evaluating toggles.
  • Bootstrap the client in tests so results do not depend on fetch timing.
  • Avoid evaluating flags in module top-level code that runs before sync.

Frequently asked questions

What causes "Unleash client "not ready""?
isEnabled is called synchronously at start-up, before the client has downloaded any toggles, so it returns the fallback.
How do I fix Unleash client "not ready"?
Wait for the client to signal readiness before evaluating any toggle.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card