{"record":{"id":"ae7ed0a154f82ad1","repo":"tursodatabase/turso","slug":"long-poll-timeout-must-be-between-1-and-int-maxva","errorCode":null,"errorMessage":"Long-poll timeout must be between 1 and {int.MaxValue} milliseconds.","messagePattern":"Long-poll timeout must be between 1 and (.+?) milliseconds\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs","lineNumber":170,"sourceCode":"\n    internal void Validate()\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(Path);\n        ArgumentException.ThrowIfNullOrWhiteSpace(ClientName);\n\n        var normalizedUri = GetNormalizedRemoteUri();\n        if (!string.IsNullOrWhiteSpace(AuthToken)\n            && normalizedUri.Scheme != Uri.UriSchemeHttps\n            && !normalizedUri.IsLoopback)\n        {\n            throw new InvalidOperationException(\n                \"Auth Token requires an HTTPS sync URL unless the host is localhost or loopback.\");\n        }\n\n        if (LongPollTimeout is { } timeout\n            && (timeout < TimeSpan.FromMilliseconds(1) || timeout.TotalMilliseconds > int.MaxValue))\n        {\n            throw new ArgumentOutOfRangeException(\n                nameof(LongPollTimeout),\n                timeout,\n                $\"Long-poll timeout must be between 1 and {int.MaxValue} milliseconds.\");\n        }\n\n        ValidateNativeSize(PushOperationsThreshold, nameof(PushOperationsThreshold));\n        ValidateNativeSize(PullBytesThreshold, nameof(PullBytesThreshold));\n        PartialSync?.Validate();\n\n        if (PartialSync is not null && !BootstrapIfEmpty)\n            throw new InvalidOperationException(\"Partial sync requires BootstrapIfEmpty=True.\");\n        if (PartialSync is not null && RemoteEncryption is not null)\n            throw new InvalidOperationException(\"Partial sync cannot be combined with remote encryption.\");\n        if (PartialSync?.Query is not null && PullBytesThreshold.HasValue)\n        {\n            throw new InvalidOperationException(\n                \"PullBytesThreshold cannot be combined with query partial bootstrap.\");\n        }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/tursodatabase/turso/blob/c1e59287258d99b309e362a63f48822256e2f65f/bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs#L152-L188","documentation":"Validate bounds LongPollTimeout to between 1 millisecond and int.MaxValue milliseconds (~24.8 days). The value is forwarded to native code as an integer millisecond count, so zero/negative values and TimeSpan values larger than int.MaxValue ms cannot be represented and are rejected with ArgumentOutOfRangeException.","triggerScenarios":"Setting LongPollTimeout to TimeSpan.Zero, a negative TimeSpan, or a value exceeding ~24.8 days (e.g. TimeSpan.FromDays(30)) when constructing TursoSyncDatabaseOptions — TursoSyncDatabaseOptions.cs:167-174.","commonSituations":"Using TimeSpan.MaxValue or Timeout constants meant for 'infinite', specifying days when the limit is ~24 days, copy-pasting a 0 timeout to disable long-polling.","solutions":["Clamp LongPollTimeout to TimeSpan.FromMilliseconds(1)..TimeSpan.FromMilliseconds(int.MaxValue).","If you intended no limit, set LongPollTimeout to null instead of a huge TimeSpan.","Use a sane value like TimeSpan.FromSeconds(30) unless you have a specific long-poll requirement."],"exampleFix":"// before\nLongPollTimeout = TimeSpan.FromDays(30)\n// after\nLongPollTimeout = TimeSpan.FromSeconds(30)","handlingStrategy":"validation","validationCode":"static TimeSpan? EnsureValidLongPollTimeout(TimeSpan? t) => t switch\n{\n    null => null,\n    var v when v < TimeSpan.FromMilliseconds(1) => throw new ArgumentOutOfRangeException(nameof(t), \"Must be >= 1ms\"),\n    var v when v.TotalMilliseconds > int.MaxValue => throw new ArgumentOutOfRangeException(nameof(t), \"Must be <= int.MaxValue ms (~24.8 days)\"),\n    _ => t\n};","typeGuard":"static bool IsValidLongPollTimeout(TimeSpan? t) => t is null || (t >= TimeSpan.FromMilliseconds(1) && t.Value.TotalMilliseconds <= int.MaxValue);","tryCatchPattern":"try { var db = new TursoSyncDatabase(opts); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(TursoSyncDatabaseOptions.LongPollTimeout))\n{\n    // clamp the value and retry\n}","preventionTips":["Don't use TimeSpan.MaxValue or day-scale values to mean 'no limit'; set LongPollTimeout = null instead.","Clamp user/config-supplied timeouts to [1ms, int.MaxValue ms] before constructing options.","Cover timeout bounds with a unit test using TursoSyncDatabaseOptions with a fake validation entry point."],"tags":["dotnet","sync","argument-out-of-range","timeout"],"backgroundTag":"invalid-timeout-value","analyzedSha":"c1e59287258d99b309e362a63f48822256e2f65f","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}