{"record":{"id":"099033065555c405","repo":"ruvnet/ruflo","slug":"connection-pool-not-initialized","errorCode":null,"errorMessage":"Connection pool not initialized","messagePattern":"Connection pool not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts","lineNumber":299,"sourceCode":"        : undefined,\n      min: poolSettings.min ?? DEFAULT_POOL_MIN,\n      max: poolSettings.max ?? this.config.poolSize ?? DEFAULT_POOL_MAX,\n      idleTimeoutMillis: poolSettings.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS,\n      connectionTimeoutMillis: this.config.connectionTimeoutMs ?? DEFAULT_CONNECTION_TIMEOUT_MS,\n      application_name: this.config.applicationName ?? 'claude-flow-ruvector',\n    };\n  }\n\n  /**\n   * Execute a query with timeout and retry logic.\n   */\n  async query<T = Record<string, unknown>>(\n    sql: string,\n    params?: unknown[],\n    timeoutMs?: number\n  ): Promise<QueryResult<T>> {\n    if (!this.pool) {\n      throw new Error('Connection pool not initialized');\n    }\n\n    const startTime = Date.now();\n    const queryId = `query-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n    const timeout = timeoutMs ?? this.config.queryTimeoutMs ?? DEFAULT_QUERY_TIMEOUT_MS;\n\n    this.emit('query:start', { queryId, sql, params });\n\n    let lastError: Error | null = null;\n    let attempt = 0;\n\n    while (attempt < this.retryConfig.maxAttempts) {\n      attempt++;\n\n      try {\n        const result = await this.executeWithTimeout<T>(sql, params, timeout);\n        const durationMs = Date.now() - startTime;\n","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts#L281-L317","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst bridge = new RuVectorBridge(config);\nconst rows = await bridge.query('SELECT 1'); // throws\n\n// after\nconst bridge = new RuVectorBridge(config);\nawait bridge.initialize();\nconst rows = await bridge.query('SELECT 1');","handlingStrategy":"validation","validationCode":"if (!isConnected(bridge)) {\n  await bridge.initialize();\n}\nconst result = await bridge.query('SELECT 1');","typeGuard":"const isQueryReady = (b: { isConnected?: boolean }): boolean =>\n  b.isConnected === true;","tryCatchPattern":"try {\n  return await bridge.query(sql, params);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Connection pool not initialized') {\n    await bridge.initialize();\n    return await bridge.query(sql, params); // single recovery attempt\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["database","connection-pool","lifecycle","initialization-order"],"backgroundTag":"not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}