{"record":{"id":"005476ba951a6b5e","repo":"go-delve/delve","slug":"detached-from-the-process","errorCode":null,"errorMessage":"detached from the process","messagePattern":"detached from the process","errorType":"exception","errorClass":"ErrProcessDetached","httpStatus":null,"severity":"info","filePath":"pkg/proc/target.go","lineNumber":28,"sourceCode":"\t\"sync\"\n\n\t\"github.com/go-delve/delve/pkg/dwarf/op\"\n\t\"github.com/go-delve/delve/pkg/goversion\"\n\t\"github.com/go-delve/delve/pkg/logflags\"\n\t\"github.com/go-delve/delve/pkg/proc/internal/ebpf\"\n)\n\nvar (\n\t// ErrNotRecorded is returned when an action is requested that is\n\t// only possible on recorded (traced) programs.\n\tErrNotRecorded = errors.New(\"not a recording\")\n\n\t// ErrNoRuntimeAllG is returned when the runtime.allg list could\n\t// not be found.\n\tErrNoRuntimeAllG = errors.New(\"could not find goroutine array\")\n\n\t// ErrProcessDetached indicates that we detached from the target process.\n\tErrProcessDetached = errors.New(\"detached from the process\")\n)\n\ntype LaunchFlags uint8\n\nconst (\n\tLaunchForeground LaunchFlags = 1 << iota\n\tLaunchDisableASLR\n)\n\n// Target represents the process being debugged.\ntype Target struct {\n\tProcess\n\n\tproc   ProcessInternal\n\trecman RecordingManipulationInternal\n\n\tpid     int\n\tCmdLine string","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/target.go#L10-L46","documentation":"ErrProcessDetached signals that delve has already detached from the target process, so the target state is no longer valid and operations on it fail. It is returned by the Valid() check that guards most TargetGroup operations. It prevents use-after-detach bugs rather than indicating a debugging failure.","triggerScenarios":"Calling any operation that first runs grp.Valid()/t.Valid() (e.g. Continue, Next, Breakpoints) after a Detach call completed on the target.","commonSituations":"Clients issuing commands after a 'detach' in the terminal; race between a Detach RPC and in-flight evaluate/continue requests in IDE integrations; scripted sessions that keep driving the API post-detach.","solutions":["Do not issue further commands after Detach; treat the session as closed","Check for ErrProcessDetached from Valid() and re-launch/reattach if more work is needed","Serialize client requests so no command runs concurrently with Detach","Create a new debugger session for the process if you need to debug again"],"exampleFix":"// before\n_, err := tgrp.Valid()\nstepErr := tgrp.Step() // fails with 'detached from the process'\n// after\nif _, err := tgrp.Valid(); errors.Is(err, proc.ErrProcessDetached) {\n    return restartSessionAndReattach()\n}","handlingStrategy":"try-catch","validationCode":"_, err := tgrp.Valid()\nif err != nil { // includes ErrProcessDetached\n    return\n}","typeGuard":"func detached(t *proc.TargetGroup) bool {\n    _, err := t.Valid()\n    return errors.Is(err, proc.ErrProcessDetached)\n}","tryCatchPattern":"if _, err := tgrp.Valid(); errors.Is(err, proc.ErrProcessDetached) {\n    // session closed; reattach or exit cleanly\n}","preventionTips":["Stop issuing commands after Detach returns","Serialize client RPCs with detach","Track session lifecycle state in your client"],"tags":["go","debugger","detach","lifecycle"],"backgroundTag":"process-already-detached","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}