tursodatabase/turso · error · NotSupportedException

Embedded replica sync is not supported yet by the .NET provi

Error message

Embedded replica sync is not supported yet by the .NET provider.

What it means

The terminal guard in SyncAsync: even when the connection is open and configured as an embedded replica, the .NET provider has not implemented replica synchronization, so every successful pre-check ends here with NotSupportedException. In practice OpenRemote() refuses to open replica connections at all, so this line exists to keep the public API honest if state ever changes.

Source

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

        return command.ExecuteNonQuery();
    }

    public void Sync()
    {
        SyncAsync(CancellationToken.None).GetAwaiter().GetResult();
    }

    public Task SyncAsync(CancellationToken cancellationToken = default)
    {
        ObjectDisposedException.ThrowIf(_disposed, this);
        if (cancellationToken.IsCancellationRequested)
            return Task.FromCanceled(cancellationToken);
        if (State != ConnectionState.Open)
            throw new InvalidOperationException("Turso database is closed.");
        if (!_connectionOptions.IsReplica)
            throw new NotSupportedException("Sync requires an embedded replica connection.");

        throw new NotSupportedException("Embedded replica sync is not supported yet by the .NET provider.");
    }

    public override void ChangeDatabase(string databaseName)
    {
        throw new NotSupportedException("Turso does not support changing the active database.");
    }

    internal int DefaultTimeout => _connectionOptions.DefaultTimeout;

    internal bool IsRemote => _remoteClient is not null;

    internal bool ReadUncommitted
    {
        get => _readUncommitted;
        set => _readUncommitted = value;
    }

    internal TursoDatabaseHandle Turso => _turso ?? throw new InvalidOperationException("Turso database is closed.");

View on GitHub (pinned to 244cde92a7)

Solutions

  1. Do not call Sync in the .NET provider: drop 'Replica Path' and use a direct remote URL so commands execute on the server directly
  2. If offline/embedded-replica semantics are required, use a binding that implements them (Rust core, Python, JS) until .NET support ships
  3. Track the provider's roadmap and re-introduce sync calls only after embedded replicas are supported

Example fix

// before
var cs = "Data Source=libsql://db.turso.io;Auth Token=...;Replica Path=local.db";
using var conn = new TursoConnection(cs);
conn.Open();
await conn.SyncAsync(); // NotSupportedException

// after
var cs = "Data Source=libsql://db.turso.io;Auth Token=...";
using var conn = new TursoConnection(cs);
conn.Open();
// direct remote: no sync step exists or is needed
Defensive patterns

Strategy: validation

Validate before calling

var opts = TursoConnectionOptions.Parse(cs);
if (opts.IsReplica)
{
    throw new ConfigurationException(
        "The .NET Turso provider does not support embedded replica sync; use a direct remote URL.");
}

Try / catch

try { await conn.SyncAsync(ct); }
catch (NotSupportedException ex) when (ex.Message.Contains("Embedded replica sync"))
{
    // provider limitation: log and continue without sync
}

Prevention

When it happens

Trigger: Any Sync()/SyncAsync() call on a connection whose options have IsReplica == true (remote Data Source plus non-empty Replica Path); periodic-sync loops ported from Turso's Rust/Python/JS bindings.

Common situations: Following Turso docs written for other language bindings; polyglot repos sharing one replica workflow across providers; upgrading from a native-wrapper package to this provider and keeping the sync timer.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/d2b51c64f745745c. Report an issue: GitHub.