{"record":{"id":"1cabb1ec2b520450","repo":"remix-run/remix","slug":"sqlite-database-method-requires-config-bas","errorCode":null,"errorMessage":"SQLite database  + method + () requires config-based construction","messagePattern":"SQLite database  \\+ method \\+ \\(\\) requires config-based construction","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/data-table-sqlite/src/lib/driver.ts","lineNumber":449,"sourceCode":"      this.#databaseOpen = false\n      this.#database.close?.()\n    }\n  }\n\n  #discardUncertainConnection(): void {\n    if (this.#config) {\n      this.#closeDatabase()\n      this.#replaceDatabase()\n    } else {\n      // The supplied client remains caller-owned, but this wrapper cannot safely\n      // reuse a connection whose transaction state is unknown.\n      this.#databaseOpen = false\n    }\n  }\n\n  #configOrThrow(method: string): SqliteDatabaseConfig {\n    if (!this.#config) {\n      throw new Error('SQLite 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('SQLite database cannot ' + method + ' while transactions are open')\n    }\n  }\n\n  #assertTransaction(token: TransactionToken): void {\n    this.#assertDatabaseOpen()\n    if (!this.#transactions.has(token.id)) {\n      throw new Error('Unknown transaction token: ' + token.id)\n    }\n  }\n","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/data-table-sqlite/src/lib/driver.ts#L431-L467","documentation":"Mirror of the Postgres driver behavior: SQLite driver methods that need the original config (such as reopening/wiping the database) throw when the driver was constructed from an existing database client, because no filename/config is available to act on.","triggerScenarios":"Constructing SqliteDatabase with a client instance (injected for tests or shared pools) and then calling a config-requiring method (the method named in the message, e.g. wipe).","commonSituations":"Test suites injecting an in-memory client then calling wipe() between tests; sharing one open DatabaseSync across modules and later needing destructive reset.","solutions":["Construct with a config ({ filename: ... }) when you need administrative operations","Pass the filename so the driver can reopen/reset the database itself","For tests, use a config-based driver pointing at a temp file instead of an injected client"],"exampleFix":"// before\nnew SqliteDatabase(new DatabaseSync(':memory:'))\nawait db.wipe() // throws\n\n// after\nnew SqliteDatabase({ filename: './test.db' })\nawait db.wipe()","handlingStrategy":"validation","validationCode":"// choose construction based on need\nlet db = needsAdminOps ? new SqliteDatabase({ filename: path }) : new SqliteDatabase(client)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use config-based construction when wipe/reset is needed","Keep a filename available for test databases","Don't rely on injected clients for admin operations"],"tags":["sqlite","driver","config","construction"],"backgroundTag":"driver-requires-config","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}