{"record":{"id":"594729112268e868","repo":"oracle/graal","slug":"this-continuation-has-failed-and-must-be-discarded","errorCode":null,"errorMessage":"This continuation has failed and must be discarded.","messagePattern":"This continuation has failed and must be discarded\\.","errorType":"exception","errorClass":"IllegalContinuationStateException","httpStatus":null,"severity":"error","filePath":"espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/ContinuationImpl.java","lineNumber":379,"sourceCode":"                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    }\n","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/ContinuationImpl.java#L361-L397","documentation":"IllegalContinuationStateException raised by resume() when the continuation previously failed (state FAILED), e.g. its entry point threw an escaping exception. A failed continuation is tainted and must be discarded; resuming is not possible.","triggerScenarios":"The entry point threw an exception, the continuation transitioned to FAILED, and code retries with resume(); catch blocks around resume() that swallow the ContinuationExecutionException and then call resume() again.","commonSituations":"Generic retry-on-exception wrappers (resilience4j-style) applied to resume(); supervisors that attempt to restart 'stuck' continuations.","solutions":["Catch ContinuationExecutionException, extract the original cause, and abandon the continuation.","Check getState()/failure handling before any retry; FAILED is terminal.","Re-run the workload by creating a new Continuation, not by resuming the failed one.","Exclude resume() from blanket retry policies."],"exampleFix":"// before\ntry {\n    continuation.resume();\n} catch (Exception e) {\n    continuation.resume(); // FAILED -> IllegalContinuationStateException\n}\n\n// after\ntry {\n    continuation.resume();\n} catch (ContinuationExecutionException e) {\n    log.error(\"workload failed\", e.getCause());\n    // discard continuation; optionally build a new one and re-run the workload\n}","handlingStrategy":"try-catch","validationCode":"if (continuation.getState() == Continuation.State.FAILED) {\n    // terminal: discard and optionally rebuild from scratch\n}","typeGuard":null,"tryCatchPattern":"try {\n    continuation.resume();\n} catch (ContinuationExecutionException e) {\n    log.error(\"workload failed\", e.getCause());\n    // discard; never resume again\n}","preventionTips":["Exclude resume() from automatic retry policies.","Treat FAILED as terminal; rebuild the workload in a new continuation.","Handle ContinuationExecutionException explicitly around resume."],"tags":["continuations","illegal-state","lifecycle","failure","graalvm","truffle"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}