{"record":{"id":"805aa184a2b6a66f","repo":"oracle/graal","slug":"this-continuation-has-already-completed-successful","errorCode":null,"errorMessage":"This continuation has already completed successfully.","messagePattern":"This continuation has already completed successfully\\.","errorType":"exception","errorClass":"IllegalContinuationStateException","httpStatus":null,"severity":"error","filePath":"espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/ContinuationImpl.java","lineNumber":378,"sourceCode":"            } finally {\n                clearExclusiveOwner();\n            }\n        } else if (updateState(State.SUSPENDED, State.RUNNING)) {\n            setExclusiveOwner();\n            try {\n                // We are ready to resume, make sure the VM has the most up-to-date frames\n                ensureDematerialized();\n                assert stackFrameHead == null;\n                return resume0();\n            } finally {\n                clearExclusiveOwner();\n            }\n        } else {\n            // illegal state for resume: neither suspended nor new\n            switch (state) {\n                case RUNNING -> throw new IllegalContinuationStateException(\"You can't resume an already executing continuation.\");\n                case COMPLETED ->\n                    throw new IllegalContinuationStateException(\"This continuation has already completed successfully.\");\n                case FAILED -> throw new IllegalContinuationStateException(\"This continuation has failed and must be discarded.\");\n                case LOCKED -> throw new IllegalContinuationStateException(\"You can't resume a continuation while it is being serialized or deserialized.\");\n                // this is racy so ensure we have a general error message in those case\n                default -> throw new IllegalContinuationStateException(\"Only new or suspended continuation can be resumed\");\n            }\n        }\n    }\n\n    @Override\n    public synchronized StackTraceElement[] getRecordedFrames() {\n        State currentState = lock();\n        try {\n            ensureDematerialized();\n            return getRecordedFrames0();\n        } finally {\n            unlock(currentState);\n        }\n    }","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/ContinuationImpl.java#L360-L396","documentation":"IllegalContinuationStateException raised by resume() when the continuation has already run to completion (state COMPLETED). A finished continuation holds no suspended frames and cannot be restarted; a new Continuation must be created instead.","triggerScenarios":"Calling resume() after resume() previously returned true (completion); looping 'while (!result) resume()' and ignoring the completion result; retry logic that blindly resumes after the entry point finished.","commonSituations":"Task-runner loops that resume until done but miss the terminal return value; re-running a one-shot job implemented as a continuation.","solutions":["Honour the boolean result of resume(): true means finished; stop resuming.","Check isCompleted() before calling resume().","Create a fresh Continuation for each new run of the workload.","Model repeated work as suspend/resume inside one lifetime, not as repeated resumes after completion."],"exampleFix":"// before\nwhile (true) {\n    continuation.resume(); // keeps throwing once completed\n}\n\n// after\nwhile (!continuation.resume()) {\n    // suspended again; do scheduling work\n}\n// resume() returned true: completed, do not resume again","handlingStrategy":"validation","validationCode":"if (continuation.isCompleted()) {\n    // finished; create a new Continuation if the work must run again\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the boolean result of resume() to terminate resume loops.","Check isCompleted() before retry loops.","Create a new continuation per run for repeatable jobs."],"tags":["continuations","illegal-state","lifecycle","graalvm","truffle"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}