tursodatabase/turso · error · Error
Encryption is not supported in this build
Error message
Encryption is not supported in this build
What it means
getCipherValue() in the native compat layer (bindings/javascript/packages/native/compat.ts:7) maps a cipher name like 'aes256gcm' to a native enum value; if the NAPI module's EncryptionCipher export is undefined it throws this error. That export is only present when the native binary was compiled with encryption support, so the throw means the loaded build simply does not contain the encryption feature. It fires as soon as you pass encryption options (cipher/key) that force cipher resolution.
Solutions
- Install/use the package variant or prebuilt binary that includes encryption support (the one whose module exports EncryptionCipher).
- If building from source, enable the encryption feature when compiling the native module, then rebuild/reinstall.
- Remove cipher/key options if the database is not actually encrypted - the throw only happens when cipher resolution is requested.
- Verify the loaded module at startup: inspect the EncryptionCipher export of the native index before constructing encrypted databases.
Example fix
// before
import { Database } from "@tursodatabase/database-native-compat";
const db = new Database("file.db", { cipher: "aes256gcm", key }); // build lacks encryption
// after
import { Database } from "@tursodatabase/database-native-compat"; // package variant WITH encryption
const db = new Database("file.db", { cipher: "aes256gcm", key }); Defensive patterns
Strategy: type-guard
Validate before calling
import { EncryptionCipher } from "#index";
const encryptionSupported = EncryptionCipher != null;
if (!encryptionSupported && opts.cipher) {
throw new Error("this native build lacks encryption; install the encryption-enabled variant");
} Type guard
import { EncryptionCipher } from "#index";
const buildSupportsEncryption = (): boolean => EncryptionCipher != null; Try / catch
try {
const db = new Database(path, { cipher, key });
} catch (e) {
if (e instanceof Error && /Encryption is not supported/.test(e.message)) {
// fall back to an encryption-enabled build or reject encrypted databases early
} else throw e;
} Prevention
- Check the EncryptionCipher export at startup before accepting encrypted-database configs.
- Pin package variants whose prebuilds include encryption; clear caches after switching.
- Gate encryption features behind a capability check so non-encryption builds degrade explicitly.
When it happens
Trigger: new Database(path, { cipher: 'aes256gcm', key }) (or any cipher option) with a native module built without the encryption feature; loading a prebuilt platform binary from a package variant that excludes encryption; a bundler/loader resolving '#index' to a stub or the wrong variant; version downgrade to a package whose binary lacked EncryptionCipher.
Common situations: Developing locally against a source build without encryption feature flags but shipping/accepting encrypted databases; mixing package variants (full vs. lite prebuilds) after an upgrade; optional-dependencies not installed so a fallback binary without encryption gets loaded; CI using a cached older binary.
Related errors
- Encryption is not supported in this build
- Unknown remote encryption cipher
- Encryption Cipher and Encryption Key are local database…
- Encryption Cipher and Encryption Key are local database…
- Encryption is not supported by
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/12f393c10756abde.
Report an issue: GitHub.
Appendix: source
Thrown at bindings/javascript/packages/native/compat.ts:7
import { DatabaseCompat, NativeDatabase, SqliteError, DatabaseOpts, EncryptionCipher } from "@tursodatabase/database-common"
import { Database as NativeDB, EncryptionCipher as NativeEncryptionCipher } from "#index";
// Map string cipher names to native enum values (lazy to avoid errors if native module lacks encryption)
function getCipherValue(cipher: EncryptionCipher): number {
if (!NativeEncryptionCipher) {
throw new Error('Encryption is not supported in this build');
}
const cipherMap: Record<EncryptionCipher, number> = {
'aes128gcm': NativeEncryptionCipher.Aes128Gcm,
'aes256gcm': NativeEncryptionCipher.Aes256Gcm,
'aegis256': NativeEncryptionCipher.Aegis256,
'aegis256x2': NativeEncryptionCipher.Aegis256x2,
'aegis128l': NativeEncryptionCipher.Aegis128l,
'aegis128x2': NativeEncryptionCipher.Aegis128x2,
'aegis128x4': NativeEncryptionCipher.Aegis128x4,
};
return cipherMap[cipher];
}
class Database extends DatabaseCompat {
constructor(path: string, opts: DatabaseOpts = {}) {
const nativeOpts: any = { ...opts };
if (opts.encryption) {
nativeOpts.encryption = {View on GitHub (pinned to 244cde92a7)