{"record":{"id":"106147e4ba4828cc","repo":"Cysharp/UniTask","slug":"not-yet-completed-unitask-only-allow-to-use-await","errorCode":null,"errorMessage":"Not yet completed, UniTask only allow to use await.","messagePattern":"Not yet completed, UniTask only allow to use await\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs","lineNumber":232,"sourceCode":"        public UniTaskStatus UnsafeGetStatus()\n        {\n            return (continuation == null || (completedCount == 0)) ? UniTaskStatus.Pending\n                 : (error == null) ? UniTaskStatus.Succeeded\n                 : (error is OperationCanceledException) ? UniTaskStatus.Canceled\n                 : UniTaskStatus.Faulted;\n        }\n\n        /// <summary>Gets the result of the operation.</summary>\n        /// <param name=\"token\">Opaque value that was provided to the <see cref=\"UniTask\"/>'s constructor.</param>\n        // [StackTraceHidden]\n        [DebuggerHidden]\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public TResult GetResult(short token)\n        {\n            ValidateToken(token);\n            if (completedCount == 0)\n            {\n                throw new InvalidOperationException(\"Not yet completed, UniTask only allow to use await.\");\n            }\n\n            if (error != null)\n            {\n                hasUnhandledError = false;\n                if (error is OperationCanceledException oce)\n                {\n                    throw oce;\n                }\n                else if (error is ExceptionHolder eh)\n                {\n                    eh.GetException().Throw();\n                }\n\n                throw new InvalidOperationException(\"Critical: invalid exception type was held.\");\n            }\n\n            return result;","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/Cysharp/UniTask/blob/ceac8d6946b1125fe782cd171fbcb245b567dbf9/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs#L214-L250","documentation":"Thrown by UniTaskCompletionSourceCore<TResult>.GetResult when completedCount is zero, meaning the source has not been signaled (no TrySetResult/TrySetException/TrySetCanceled was called). UniTask is await-only by design: calling GetResult directly on an incomplete source is invalid. The guard prevents reading an uninitialized result.","triggerScenarios":"Manually calling GetResult on a UniTaskCompletionSourceCore before it is completed. Awaiting a UniTask whose underlying source was never signaled (e.g., a forgotten TrySetResult). Using UniTask.SuppressCancellationThrow() or direct GetResult() on a task that is still pending.","commonSituations":"Forgetting to call TrySetResult in a callback-based adapter. A code path that creates a UniTaskCompletionSource<T> but the signaling branch is unreachable due to a logic error. Manual interaction with IUniTaskSource outside of the await pattern.","solutions":["Ensure every code path that creates a UniTaskCompletionSource calls TrySetResult, TrySetException, or TrySetCanceled","Use await instead of manually calling GetResult — UniTask is designed for await-only consumption","Check status before GetResult: if (source.GetStatus(token) != UniTaskStatus.Pending) before accessing the result"],"exampleFix":"// before\nvar tcs = new UniTaskCompletionSourceCore<int>();\nvar result = tcs.GetResult(tcs.Version); // throws: not completed\n\n// after\nvar tcs = new UniTaskCompletionSourceCore<int>();\ntcs.TrySetResult(42);\nvar result = tcs.GetResult(tcs.Version); // ok","handlingStrategy":"validation","validationCode":"if (source.GetStatus(token) == UniTaskStatus.Pending)\n{\n    // not ready; await instead of calling GetResult\n    throw new InvalidOperationException(\"Source not yet completed; use await.\");\n}\nvar result = source.GetResult(token);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always await UniTask rather than calling GetResult manually","Ensure all code paths signal TrySetResult/TrySetException/TrySetCanceled","Add a timeout signal so sources always complete"],"tags":["unitask","completion-source","await-violation","unity","csharp"],"backgroundTag":null,"analyzedSha":"ceac8d6946b1125fe782cd171fbcb245b567dbf9","analyzedAt":"2026-08-13T19:16:39.025Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}