ruvnet/ruflo · error
Connection pool not initialized
Error message
Connection pool not initialized
What it means
Thrown by the pool manager's query() when this.pool is undefined, i.e. initialize() was never called (or did not complete) on this instance. Queries are only legal after a successful initialize() created the pg.Pool; this guard prevents an opaque 'cannot read property query of undefined'.
Source
Thrown at v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts:299
: undefined,
min: poolSettings.min ?? DEFAULT_POOL_MIN,
max: poolSettings.max ?? this.config.poolSize ?? DEFAULT_POOL_MAX,
idleTimeoutMillis: poolSettings.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS,
connectionTimeoutMillis: this.config.connectionTimeoutMs ?? DEFAULT_CONNECTION_TIMEOUT_MS,
application_name: this.config.applicationName ?? 'claude-flow-ruvector',
};
}
/**
* Execute a query with timeout and retry logic.
*/
async query<T = Record<string, unknown>>(
sql: string,
params?: unknown[],
timeoutMs?: number
): Promise<QueryResult<T>> {
if (!this.pool) {
throw new Error('Connection pool not initialized');
}
const startTime = Date.now();
const queryId = `query-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
const timeout = timeoutMs ?? this.config.queryTimeoutMs ?? DEFAULT_QUERY_TIMEOUT_MS;
this.emit('query:start', { queryId, sql, params });
let lastError: Error | null = null;
let attempt = 0;
while (attempt < this.retryConfig.maxAttempts) {
attempt++;
try {
const result = await this.executeWithTimeout<T>(sql, params, timeout);
const durationMs = Date.now() - startTime;
View on GitHub (pinned to fa13ee4ad6)
Solutions
- Await initialize() (and confirm it succeeded) before issuing any query
- Gate query paths on the manager's connected/isConnected state and re-run initialize() or fail fast otherwise
- If initialize() previously failed, surface that error at startup instead of letting later queries hit this guard
Example fix
// before
const bridge = new RuVectorBridge(config);
const rows = await bridge.query('SELECT 1'); // throws
// after
const bridge = new RuVectorBridge(config);
await bridge.initialize();
const rows = await bridge.query('SELECT 1'); Defensive patterns
Strategy: validation
Validate before calling
if (!isConnected(bridge)) {
await bridge.initialize();
}
const result = await bridge.query('SELECT 1'); Type guard
const isQueryReady = (b: { isConnected?: boolean }): boolean =>
b.isConnected === true; Try / catch
try {
return await bridge.query(sql, params);
} catch (err) {
if (err instanceof Error && err.message === 'Connection pool not initialized') {
await bridge.initialize();
return await bridge.query(sql, params); // single recovery attempt
}
throw err;
} Prevention
- Await initialize() during bootstrap and block query traffic until it resolves
- If init fails, crash or re-init — never continue serving queries against an uninitialized bridge
- Wrap query paths in a thin repository layer that owns the readiness check
When it happens
Trigger: Calling query() in a constructor or module top-level that runs before the async initialize() resolves; a query issued after initialize() failed (pool stays unset) because the failure was swallowed; two module instances where only one was initialized.
Common situations: Forgetting to await an init step in startup ordering; error handlers that log-and-continue past a failed initialize(); tests that stub query() paths without booting the pool.
Related errors
- Connection pool already initialized
- RuVector Bridge not initialized. Call initialize() first.
- Connection pool is shutting down
- Plugin ${this.metadata.name} not initialized
- Failed to initialize connection pool: ${(error as Error).mes
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/099033065555c405.
Report an issue: GitHub.