tursodatabase/turso · error · Error
not implemented
Error message
not implemented
What it means
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.
Source
Thrown at bindings/javascript/packages/common/compat.ts:230
if (typeof source !== "string")
throw new TypeError("Expected first argument to be a string");
if (typeof options !== "object")
throw new TypeError("Expected second argument to be an options object");
const pragma = `PRAGMA ${source}`;
const stmt = this.prepare(pragma);
try {
const results = stmt.all();
return results;
} finally {
stmt.close();
}
}
backup(filename, options) {
throw new Error("not implemented");
}
serialize(options) {
throw new Error("not implemented");
}
function(name, options, fn) {
throw new Error("not implemented");
}
aggregate(name, options) {
throw new Error("not implemented");
}
table(name, factory) {
throw new Error("not implemented");
}
View on GitHub (pinned to bad083fafb)
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
Example fix
// before
db.backup('/tmp/backup.db'); // throws not implemented
// after
db.exec("VACUUM INTO '/tmp/backup.db'"); Defensive patterns
Strategy: fallback
Validate before calling
const supportsBackup = !db.backup.toString().includes('not implemented');
if (supportsBackup) db.backup(dest);
else db.exec(`VACUUM INTO '${dest}'`); Type guard
function supportsDbBackup(db: Database): boolean {
try {
return !/not implemented/.test(String(db.backup));
} catch {
return false;
}
} Try / catch
try {
db.backup(dest);
} catch (err) {
if (err instanceof Error && err.message === 'not implemented') {
db.exec(`VACUUM INTO '${dest}'`); // consistent snapshot via SQL
} else {
throw err;
}
} Prevention
- 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
When it happens
Trigger: 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().
Common situations: 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.
Related errors
- The database connection is not open
- The supplied SQL string contains no statements
- Expected first argument to be a function
- Expected first argument to be a string
- Expected second argument to be an options object
AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16).
Data as JSON: /api/errors/cc56e0e31e8bdf02.
Report an issue: GitHub.