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 maps cipher names ('aes256gcm', 'aegis256', ...) to the native EncryptionCipher enum, but builds the map lazily so the module still loads when the native addon lacks encryption. If the imported NativeEncryptionCipher is undefined — the binary was compiled without encryption support — passing any encryption option throws this error at Database construction. It is a build-capability error, not a wrong-cipher error.

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 bad083fafb)

Solutions

  1. Upgrade the @tursodatabase/native package (and its platform binaries) to a version built with encryption support.
  2. If building the addon from source, enable the encryption feature when compiling.
  3. Feature-check before constructing: import { EncryptionCipher } from '#index' and verify it is non-null.
  4. If encryption is optional in your app, degrade gracefully by dropping encryptionKey/encryptionCipher.

Example fix

// before
import { EncryptionCipher } from '#index';
const db = new Database('app.db', { encryptionKey, encryptionCipher: 'aes256gcm' }); // throws if build lacks encryption

// after
import { EncryptionCipher } from '#index';
if (!EncryptionCipher) {
  throw new Error('native build lacks encryption; upgrade @tursodatabase/native platform binaries');
}
const db = new Database('app.db', { encryptionKey, encryptionCipher: 'aes256gcm' });
Defensive patterns

Strategy: type-guard

Validate before calling

import { EncryptionCipher } from '#index';
if (EncryptionCipher == null) {
  throw new Error('this native build lacks encryption; upgrade the native package before using encryptionKey');
}
const db = new Database(path, { encryptionKey, encryptionCipher: 'aes256gcm' });

Type guard

const supportsEncryption = (enc: unknown): enc is Record<string, number> =>
  enc != null && typeof (enc as Record<string, unknown>).Aes256Gcm === 'number';

Try / catch

try { new Database(path, opts); } catch (e) { if (e instanceof Error && /Encryption is not supported/.test(e.message)) { /* fall back: open unencrypted or upgrade native binary */ } else throw e; }

Prevention

When it happens

Trigger: new Database(path, { encryptionKey, encryptionCipher }) on @tursodatabase/database-native compat flavor where the loaded native binary has no EncryptionCipher export; older prebuilt platform binaries; self-compiled addons without the encryption feature enabled.

Common situations: Upgrading the JS packages without upgrading the native binary (or vice versa); optionalDependencies pulling a stale platform package; CI using a minimal local build; deploying on a platform whose prebuilt artifact lacks encryption.

Related errors


AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16). Data as JSON: /api/errors/12f393c10756abde. Report an issue: GitHub.