tursodatabase/turso · error · ArgumentOutOfRangeException

Sync Interval must be between 0 and {MaximumSyncIntervalSeco

Error message

Sync Interval must be between 0 and {MaximumSyncIntervalSeconds} seconds.

What it means

The SyncInterval property getter validates that the configured sync interval is within [0, MaximumSyncIntervalSeconds]; values outside that range throw ArgumentOutOfRangeException naming SyncInterval. This fails fast on connection-options misconfiguration.

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoConnectionOptions.cs:44

    public bool Pooling => _builder.Pooling;

    public string DataSource => _builder.DataSource;

    public string AuthToken => _builder.AuthToken;

    public string ReplicaPath => _builder.ReplicaPath;

    public bool ReadYourWrites => _builder.ReadYourWrites;

    public int SyncInterval
    {
        get
        {
            var value = _builder.SyncInterval;
            if (value is < 0 or > MaximumSyncIntervalSeconds)
            {
                throw new ArgumentOutOfRangeException(
                    nameof(SyncInterval),
                    value,
                    $"Sync Interval must be between 0 and {MaximumSyncIntervalSeconds} seconds.");
            }

            return value;
        }
    }

    public string SyncClientName => _builder.SyncClientName;

    public int SyncLongPollTimeout => _builder.SyncLongPollTimeout;

    public bool BootstrapIfEmpty => _builder.BootstrapIfEmpty;

    public int PartialBootstrapPrefix => _builder.PartialBootstrapPrefix;

    public string PartialBootstrapQuery => _builder.PartialBootstrapQuery;

View on GitHub (pinned to 6c72522679)

Solutions

  1. Set SyncInterval to a value between 0 and MaximumSyncIntervalSeconds seconds.
  2. Clamp the value before assigning: Math.Clamp(configured, 0, TursoConnectionOptions.MaximumSyncIntervalSeconds).
  3. Fix the unit: if you have milliseconds, divide by 1000 before assigning.

Example fix

// before
builder.SyncInterval = 60000; // ms, too large
// after
builder.SyncInterval = Math.Clamp(60, 0, TursoConnectionOptions.MaximumSyncIntervalSeconds);
Defensive patterns

Strategy: validation

Validate before calling

int clamped = Math.Clamp(configuredIntervalSeconds, 0, TursoConnectionOptions.MaximumSyncIntervalSeconds);
builder.SyncInterval = clamped;

Type guard

static bool IsValidSyncInterval(int seconds) => seconds is >= 0 and <= TursoConnectionOptions.MaximumSyncIntervalSeconds;

Try / catch

try { var interval = options.SyncInterval; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(TursoConnectionOptions.SyncInterval))
{ /* log bad config and use default */ }

Prevention

When it happens

Trigger: Constructing TursoConnectionOptions / a connection string builder with SyncInterval set to a negative number or a value larger than MaximumSyncIntervalSeconds, then reading the SyncInterval property.

Common situations: Passing milliseconds instead of seconds (e.g. SyncInterval=60000); copy-pasting a TimeSpan value into an int seconds field; reading the interval from unvalidated app config.

Related errors


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