tursodatabase/turso · error · NotSupportedException

Sync Interval requires an embedded replica connection.

Error message

Sync Interval requires an embedded replica connection.

What it means

SyncInterval is a replica-only option: it schedules periodic background syncs of an embedded replica. OpenRemote detects a remote Turso URL and checks replica options; setting SyncInterval > 0 on a plain remote (non-replica) connection is a configuration contradiction, so Open throws NotSupportedException.

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoConnection.cs:468

        {
            remoteClient.CloseAsync(DefaultTimeout, CancellationToken.None).GetAwaiter().GetResult();
        }
        catch
        {
            InvalidateRemoteSession();
        }
    }

    private void OpenRemote()
    {
        if (_connectionOptions.IsReplica)
        {
            OpenReplica();
            return;
        }

        if (_connectionOptions.SyncInterval > 0)
            throw new NotSupportedException("Sync Interval requires an embedded replica connection.");
        if (_connectionOptions.HasAdvancedReplicaOptions)
            throw new NotSupportedException("Advanced sync options require an embedded replica connection.");

        if (_connectionOptions.GetEncryptionCipher().HasValue || !string.IsNullOrWhiteSpace(_connectionOptions["Encryption Key"]))
            throw new InvalidOperationException("Encryption Cipher and Encryption Key are local database options and cannot be used with remote Turso URLs.");

        var handler = RemoteMessageHandlerFactory?.Invoke();
        _remoteClient = handler is null
            ? new TursoRemoteClient(_connectionOptions.GetRemoteUri(), _connectionOptions.AuthToken)
            : new TursoRemoteClient(
                new HttpClient(handler),
                _connectionOptions.GetRemoteUri(),
                _connectionOptions.AuthToken,
                disposeHttpClient: true);
    }

    private void OpenReplica()
    {

View on GitHub (pinned to 6c72522679)

Solutions

  1. Remove SyncInterval from the connection string if you want a plain remote connection.
  2. Switch to an embedded-replica connection string (local file path + remote URL) to keep periodic syncs.
  3. Call Sync/SyncAsync manually on demand instead of using the interval option.

Example fix

// before
var cs = "Data Source=turso://mydb-myorg.turso.io;SyncInterval=60;";
// after
var cs = "Data Source=/local/replica.db;Uri=turso://mydb-myorg.turso.io;SyncInterval=60;";
Defensive patterns

Strategy: validation

Validate before calling

var b = new DbConnectionStringBuilder { ConnectionString = cs };
bool isRemote = (b.ContainsKey("Data Source") && (b["Data Source"] as string ?? "").StartsWith("turso://"));
if (isRemote && b.ContainsKey("SyncInterval")) throw new NotSupportedException("SyncInterval needs an embedded replica");

Try / catch

try { conn.Open(); } catch (NotSupportedException ex) when (ex.Message.Contains("Sync Interval")) { /* strip SyncInterval or switch to replica connection string */ }

Prevention

When it happens

Trigger: Opening a TursoConnection whose connection string is a remote turso:// URL (OpenRemote path) while SyncInterval=... is present in the connection string/options.

Common situations: Copying a replica connection string and swapping only the URL to a remote one, misunderstanding that SyncInterval works with pure remote connections, migrating from embedded replica to remote-only and leaving the option behind.

Related errors


AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-31). Data as JSON: /api/errors/cb33f6f50ce96891. Report an issue: GitHub.