ruvnet/ruflo · error · Error
Store not initialized. Call initialize() first.
Error message
Store not initialized. Call initialize() first.
What it means
PatternStore#search() throws this when this.registry is null. The registry is only populated by the async initialize() method, which dynamically imports discovery/download/publish modules and calls discovery.discoverRegistry(). Critically, initialize() returns false instead of throwing when registry discovery fails, so awaiting it is not enough — you must also check its boolean result before calling search().
Source
Thrown at v3/@claude-flow/cli/src/transfer/store/index.ts:131
this.discovery = new PatternDiscovery(this.config);
this.downloader = new PatternDownloader(this.config);
this.publisher = new PatternPublisher(this.config);
const result = await this.discovery.discoverRegistry(registryName);
if (result.success && result.registry) {
this.registry = result.registry;
return true;
}
return false;
}
/**
* Search patterns
*/
search(options: SearchOptions = {}): SearchResult {
if (!this.registry) {
throw new Error('Store not initialized. Call initialize() first.');
}
return doSearchPatterns(this.registry, options);
}
/**
* Get pattern by ID
*/
getPattern(patternId: string): PatternEntry | undefined {
if (!this.registry) {
throw new Error('Store not initialized. Call initialize() first.');
}
return this.registry.patterns.find(p => p.id === patternId);
}
/**
* Download pattern
*/
async download(View on GitHub (pinned to fa13ee4ad6)
Solutions
- Call and await initialize() before any registry-backed method: `await store.initialize()`.
- Check the result: `if (!(await store.initialize())) { throw new Error('pattern registry unreachable'); }` so discovery failures surface immediately instead of later as this error.
- If initialize() returns false, debug the environment: network access and the registry config (StoreConfig) passed to the constructor.
- In long-lived processes, re-initialize after connectivity outages instead of reusing a failed store.
Example fix
// before
const store = new PatternStore(config);
const results = store.search({ query: 'auth' }); // throws: Store not initialized
// after
const store = new PatternStore(config);
const ready = await store.initialize();
if (!ready) throw new Error('registry discovery failed — check network/registry config');
const results = store.search({ query: 'auth' }); Defensive patterns
Strategy: validation
Validate before calling
const store = new PatternStore(config);
const ready = await store.initialize();
if (!ready) {
throw new Error('PatternStore init failed: registry unreachable — check network/registry config');
}
// only now is search() safe
const results = store.search({ query: 'auth' }); Try / catch
try {
return store.search(options);
} catch (err) {
if (err instanceof Error && err.message === 'Store not initialized. Call initialize() first.') {
if (!(await store.initialize())) throw new Error('registry discovery failed');
return store.search(options); // retry once after proper init
}
throw err;
} Prevention
- Always await initialize() and branch on its boolean result — false means discovery failed even though nothing threw
- Wrap store creation in a factory that returns an already-initialized store so callers cannot skip the step
- In tests, mock discoverRegistry to succeed instead of constructing half-initialized stores
- Log the initialize() return value; silent false is the root cause of most late 'not initialized' crashes
When it happens
Trigger: (1) `const store = new PatternStore(); store.search({...})` without ever calling initialize(); (2) calling search() before `await store.initialize()` resolves (e.g. constructor-time or module-top-level usage); (3) initialize() was awaited but returned false because discoverRegistry() failed (offline, bad registry URL) and the caller ignored the return value.
Common situations: Refactoring that moved initialization into a constructor or top-level code; unit tests that construct PatternStore directly without mocks for discovery; running in a sandbox with no network access to the pattern registry, so initialize() quietly returns false.
Related errors
- SDKBridge not initialized. Call initialize() first.
- SONAAdapter not initialized. Call initialize() first.
- SwarmAdapter not initialized. Call initialize() first.
- Worker ${this.id} not initialized. Call initialize() first.
- ruvLLM bridge not initialized. Call with config first.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/614d65e7af15ea33.
Report an issue: GitHub.