{"record":{"id":"fddb2d915b4d096e","repo":"remix-run/remix","slug":"mysql-database-method-requires-config-base","errorCode":null,"errorMessage":"MySQL database  + method + () requires config-based construction","messagePattern":"MySQL database  \\+ method \\+ \\(\\) requires config-based construction","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/data-table-mysql/src/lib/driver.ts","lineNumber":477,"sourceCode":"    // tracked to keep close() idempotent.\n    if (isMysqlPool(this.#client) && !this.#poolClosed) {\n      this.#poolClosed = true\n      await this.#client.end()\n    }\n  }\n\n  async #replacePool(): Promise<void> {\n    await this.#closePool().catch(() => undefined)\n\n    if (this.#config) {\n      this.#client = createMysqlPool(this.#config)\n      this.#poolClosed = false\n    }\n  }\n\n  #configOrThrow(method: string): string | MysqlPoolOptions {\n    if (!this.#config) {\n      throw new Error('MySQL database ' + method + '() requires config-based construction')\n    }\n\n    return this.#config\n  }\n\n  #assertNoOpenTransactions(method: string): void {\n    if (this.#transactions.size > 0) {\n      throw new Error('MySQL database cannot ' + method + ' while transactions are open')\n    }\n  }\n\n  #resolveClient(token: TransactionToken | undefined): MysqlQueryable {\n    if (!token) {\n      return this.#client\n    }\n\n    return this.#transactionConnection(token)\n  }","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/data-table-mysql/src/lib/driver.ts#L459-L495","documentation":"The MySQL driver supports two construction modes: config-based (pool-managed) and client-based (external connection). Methods that need to create or manage the pool — signalled by #configOrThrow — throw this error when called on a driver built from an existing client, because there is no config to build a pool from.","triggerScenarios":"Constructing the driver with new MysqlDriver(client) (or an equivalent client-injection factory) and then calling a pool-requiring method such as connect/config-dependent lifecycle operations; typically surfaced via a method named in the message, e.g. 'MySQL database wipe() requires config-based construction'.","commonSituations":"Using an injected client for tests or a managed connection, then calling wipe/reset/pool operations during teardown; switching from config-based to client-based construction without auditing lifecycle calls.","solutions":["Construct the driver from a config object (host/user/password/database or uri) so pool-managing methods work","If you must keep the external client, avoid the pool-requiring method and perform the equivalent operation directly on your client","Check the method name in the error message to identify which call needs config"],"exampleFix":"// before\nconst driver = createMysqlDriver(existingClient)\nawait driver.wipe()\n// after\nconst driver = createMysqlDriver({ uri: MYSQL_URI })\nawait driver.wipe()","handlingStrategy":"validation","validationCode":"// Decide based on construction mode before calling pool-requiring methods\nconst driverFromConfig = createMysqlDriver({ uri: process.env.MYSQL_URL! })\n// use driverFromConfig for wipe()/pool lifecycle; keep client-based drivers for scoped queries","typeGuard":null,"tryCatchPattern":"try { await driver.wipe() } catch (e) { if (e instanceof Error && e.message.includes('requires config-based construction')) { /* rebuild driver from config or clean manually */ } throw e }","preventionTips":["Use config-based construction when you need lifecycle management","Reserve client-based drivers for injected-connection scenarios without wipe/pool calls"],"tags":["data-table","mysql","driver","configuration"],"backgroundTag":"invalid-driver-configuration","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}