tursodatabase/turso · error · Error

Encryption is not supported in this build

Error message

Encryption is not supported in this build

What it means

Same guard as the compat flavor, but in the native promise layer: getCipherValue() needs the native EncryptionCipher enum to translate cipher names, and throws when the loaded native addon does not export it. The lazy check exists so the error appears only when encryption is actually requested, at Database construction time. It signals the binary was built without encryption support.

Source

Thrown at bindings/javascript/packages/native/promise.ts:7

import { DatabasePromise, NativeDatabase, SqliteError, DatabaseOpts, EncryptionCipher, Transaction } 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 DatabasePromise {
    constructor(path: string, opts: DatabaseOpts = {}) {
        const nativeOpts: any = { ...opts };
        if (opts.encryption) {
            nativeOpts.encryption = {

View on GitHub (pinned to bad083fafb)

Solutions

  1. Update @tursodatabase/native and matching platform binaries to an encryption-enabled build.
  2. Rebuild the native module from source with encryption enabled if you self-host binaries.
  3. Add a startup feature check on the EncryptionCipher import and fail with a clear message.
  4. If you never intended encryption, remove encryptionKey/encryptionCipher options.

Example fix

// before
const db = new Database('app.db', { encryptionKey, encryptionCipher: 'aegis256' }); // throws on builds without encryption

// after
import { EncryptionCipher as Enc } from '#index';
if (Enc == null) {
  throw new Error('encryption unavailable in this native build; upgrade the native package');
}
const db = new Database('app.db', { encryptionKey, encryptionCipher: 'aegis256' });
Defensive patterns

Strategy: type-guard

Validate before calling

import { EncryptionCipher } from '#index';
if (!EncryptionCipher) {
  throw new Error('encryption unavailable in this native build; upgrade @tursodatabase/native');
}
const db = new Database(path, { encryptionKey, encryptionCipher: 'aegis256' });

Type guard

const supportsEncryption = (enc: unknown): enc is object => enc != null;

Try / catch

try { const db = new Database(path, { encryptionKey, encryptionCipher }); } catch (e) { if (e instanceof Error && /Encryption is not supported in this build/.test(e.message)) { /* upgrade binary or open without encryption */ } else throw e; }

Prevention

When it happens

Trigger: new Database(path, { encryptionKey, encryptionCipher }) in the promise flavor of @tursodatabase/database-native where NativeEncryptionCipher is undefined; version skew between the JS wrapper and the native addon; platforms whose prebuilt binary omits encryption.

Common situations: Lockfile pinning an old @tursodatabase/{platform} package while the wrapper expects the encryption enum; local debug builds of the NAPI addon; Docker images cached with stale native artifacts.

Related errors


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