{"record":{"id":"561688cb304688c2","repo":"Cysharp/UniTask","slug":"exceed-timeout","errorCode":null,"errorMessage":"Exceed Timeout:","messagePattern":"Exceed Timeout:","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"error","filePath":"src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs","lineNumber":401,"sourceCode":"                (winArgIndex, taskResultIsCanceled, _) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask);\n            }\n            catch\n            {\n                delayCancellationTokenSource.Cancel();\n                delayCancellationTokenSource.Dispose();\n                throw;\n            }\n\n            // timeout\n            if (winArgIndex == 1)\n            {\n                if (taskCancellationTokenSource != null)\n                {\n                    taskCancellationTokenSource.Cancel();\n                    taskCancellationTokenSource.Dispose();\n                }\n\n                throw new TimeoutException(\"Exceed Timeout:\" + timeout);\n            }\n            else\n            {\n                delayCancellationTokenSource.Cancel();\n                delayCancellationTokenSource.Dispose();\n            }\n\n            if (taskResultIsCanceled)\n            {\n                Error.ThrowOperationCanceledException();\n            }\n        }\n\n        public static async UniTask<T> Timeout<T>(this UniTask<T> task, TimeSpan timeout, DelayType delayType = DelayType.DeltaTime, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null)\n        {\n            var delayCancellationTokenSource = new CancellationTokenSource();\n            var timeoutTask = UniTask.Delay(timeout, delayType, timeoutCheckTiming, delayCancellationTokenSource.Token).SuppressCancellationThrow();\n","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/Cysharp/UniTask/blob/ceac8d6946b1125fe782cd171fbcb245b567dbf9/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs#L383-L419","documentation":"Thrown by UniTask.Timeout (non-generic) when the timeout delay wins the WhenAny race (winArgIndex == 1) before the wrapped task completes. This is the intended timeout behavior: the task did not finish within the specified TimeSpan, so UniTask cancels the task's CancellationTokenSource (if provided) and throws TimeoutException. The task itself is cancelled as a side effect.","triggerScenarios":"Calling await task.Timeout(TimeSpan.FromSeconds(5)) where the task takes longer than 5 seconds. Network requests, file I/O, or long-running computations wrapped with .Timeout() that exceed the configured deadline.","commonSituations":"Slow or unresponsive external systems (servers, databases). Network latency spikes. Deadlocks or contention causing tasks to stall. Configuring an unrealistically short timeout. Tasks that block on locks or never-complete awaits.","solutions":["Increase the timeout value to accommodate expected latency","Investigate and optimize the wrapped task to complete faster","Use TimeoutWithoutException if you want to handle the timeout as a boolean rather than an exception","Catch TimeoutException explicitly and provide a fallback or retry"],"exampleFix":"// before\nawait someNetworkCall.Timeout(TimeSpan.FromSeconds(1));\n\n// after (option 1: longer timeout)\nawait someNetworkCall.Timeout(TimeSpan.FromSeconds(10));\n\n// after (option 2: suppress)\nbool timedOut = await someNetworkCall.TimeoutWithoutException(TimeSpan.FromSeconds(5));\nif (timedOut) { /* fallback */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await task.Timeout(timeout);\n}\ncatch (TimeoutException ex)\n{\n    // handle timeout: fallback, retry, or log\n    Debug.LogWarning($\"Task timed out: {ex.Message}\");\n}","preventionTips":["Set realistic timeout values based on expected worst-case latency","Use TimeoutWithoutException when you want a boolean result instead of an exception","Investigate and optimize the wrapped task if timeouts are frequent","Consider retry logic with exponential backoff for transient slowness"],"tags":["unitask","timeout","cancellation","unity","csharp"],"backgroundTag":null,"analyzedSha":"ceac8d6946b1125fe782cd171fbcb245b567dbf9","analyzedAt":"2026-08-13T19:16:39.025Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}