{"record":{"id":"c8161ce3e6f64d31","repo":"egametang/ET","slug":"taskt-transitiontofinal-alreadycompleted","errorCode":null,"errorMessage":"TaskT_TransitionToFinal_AlreadyCompleted","messagePattern":"TaskT_TransitionToFinal_AlreadyCompleted","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/ETTask/ETTask.cs","lineNumber":212,"sourceCode":"                    this.Recycle();\n                    break;\n                case AwaiterStatus.Faulted:\n                    ExceptionDispatchInfo c = this.callback as ExceptionDispatchInfo;\n                    this.callback = null;\n                    this.Recycle();\n                    c?.Throw();\n                    break;\n                default:\n                    throw new NotSupportedException(\"ETTask does not allow call GetResult directly when task not completed. Please use 'await'.\");\n            }\n        }\n\n        [DebuggerHidden]\n        public void SetResult()\n        {\n            if (this.state != AwaiterStatus.Pending)\n            {\n                throw new InvalidOperationException(\"TaskT_TransitionToFinal_AlreadyCompleted\");\n            }\n\n            this.state = AwaiterStatus.Succeeded;\n\n            Action c = this.callback as Action;\n            this.callback = null;\n            c?.Invoke();\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        [DebuggerHidden]\n        public void SetException(Exception e)\n        {\n            if (this.state != AwaiterStatus.Pending)\n            {\n                throw new InvalidOperationException(\"TaskT_TransitionToFinal_AlreadyCompleted\");\n            }\n","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/ETTask/ETTask.cs#L194-L230","documentation":"Thrown by ETTask.SetResult() when the task's state is no longer Pending — i.e. it was already completed (Succeeded or Faulted). ETTask objects may be pooled/reused, so completing a task twice corrupts state and is rejected with InvalidOperationException. Usually indicates double-completion, reuse-after-recycle, or a race where two paths resolve the same task.","triggerScenarios":"Calling SetResult twice on the same ETTask; resolving a task both via SetResult and SetException; a recycled/pooled task being completed by stale code; concurrent fibers resolving the same task.","commonSituations":"Object-pool reuse without resetting state; fire-and-forget code paths (.Coroutine()) that also complete the task; cancellation token firing after SetResult; bugs where an awaiter callback and the producer both complete the task.","solutions":["Guard completions: if (task.state == AwaiterStatus.Pending) task.SetResult();","Ensure exactly one code path owns task completion; route cancellation through the token, not a second SetResult/SetException.","Avoid handing the same ETTask instance to multiple resolvers; do not reuse pooled tasks before reset."],"exampleFix":"// before\ntask.SetResult();\ntask.SetResult(); // throws TaskT_TransitionToFinal_AlreadyCompleted\n\n// after\ntask.SetResult();\n// ensure no second completion; if needed, check state first.","handlingStrategy":"validation","validationCode":"// Complete at most once.\nif (task.state == AwaiterStatus.Pending) task.SetResult();","typeGuard":null,"tryCatchPattern":"try { task.SetResult(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"AlreadyCompleted\")) { /* log duplicate completion; ignore */ }","preventionTips":["Assign a single owner responsible for task completion.","Route cancellation through the token, not a second SetException/SetResult.","Do not reuse pooled ETTask instances before they are reset."],"tags":["ettask","async","coroutine","double-completion","csharp","unity"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}