{"record":{"id":"cc56e0e31e8bdf02","repo":"tursodatabase/turso","slug":"not-implemented","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/common/compat.ts","lineNumber":230,"sourceCode":"    if (typeof source !== \"string\")\n      throw new TypeError(\"Expected first argument to be a string\");\n\n    if (typeof options !== \"object\")\n      throw new TypeError(\"Expected second argument to be an options object\");\n\n    const pragma = `PRAGMA ${source}`;\n\n    const stmt = this.prepare(pragma);\n    try {\n      const results = stmt.all();\n      return results;\n    } finally {\n      stmt.close();\n    }\n  }\n\n  backup(filename, options) {\n    throw new Error(\"not implemented\");\n  }\n\n  serialize(options) {\n    throw new Error(\"not implemented\");\n  }\n\n  function(name, options, fn) {\n    throw new Error(\"not implemented\");\n  }\n\n  aggregate(name, options) {\n    throw new Error(\"not implemented\");\n  }\n\n  table(name, factory) {\n    throw new Error(\"not implemented\");\n  }\n","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/common/compat.ts#L212-L248","documentation":"Database.backup() is a stub in the Turso better-sqlite3 compatibility layer. The method exists so that better-sqlite3 code parses, but calling it always throws 'not implemented' because the underlying online-backup API has not been wired up to the Turso engine yet.","triggerScenarios":"Calling db.backup('/path/to/file.db') directly; running better-sqlite3 application code unmodified against the Turso bindings; test suites or migration scripts that snapshot the database via backup().","commonSituations":"Porting an existing better-sqlite3 project to Turso; CI pipelines that create a backup copy of the database file before running destructive tests; tools that periodically back up the live database.","solutions":["Replace backup() with SQL: run db.exec(\"VACUUM INTO '/path/to/file.db'\") to produce a consistent snapshot file","Or copy the database file when no connection has it open (after close())","Feature-detect before calling: if (db.backup.toString().includes('not implemented')) fallback","Track/await upstream support for the backup API in the Turso bindings"],"exampleFix":"// before\ndb.backup('/tmp/backup.db'); // throws not implemented\n\n// after\ndb.exec(\"VACUUM INTO '/tmp/backup.db'\");","handlingStrategy":"fallback","validationCode":"const supportsBackup = !db.backup.toString().includes('not implemented');\nif (supportsBackup) db.backup(dest);\nelse db.exec(`VACUUM INTO '${dest}'`);","typeGuard":"function supportsDbBackup(db: Database): boolean {\n  try {\n    return !/not implemented/.test(String(db.backup));\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  db.backup(dest);\n} catch (err) {\n  if (err instanceof Error && err.message === 'not implemented') {\n    db.exec(`VACUUM INTO '${dest}'`); // consistent snapshot via SQL\n  } else {\n    throw err;\n  }\n}","preventionTips":["Audit ported better-sqlite3 code for backup() before switching to Turso","Prefer VACUUM INTO from day one so code is engine-portable","Advertise unsupported methods loudly at startup instead of failing mid-operation"],"tags":["turso","javascript","backup","not-implemented","better-sqlite3-compat"],"backgroundTag":"method-not-implemented","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}