chenhg5/cc-connect · error
session is closed
Error message
session is closed
What it means
A sentinel liveness guard on cursorSession.Send: the session is no longer alive (Close() ran or the context cancelled), so launching another Cursor turn is rejected before any staging or spawning happens.
Source
Thrown at agent/cursor/session.go:105
// Feishu image messages carry no filename — synthesise one so
// the file lands with a correct extension.
name = fmt.Sprintf("img_%d_%d%s", time.Now().UnixMilli(), i, core.ExtFromMime(im.MimeType))
}
imgFiles = append(imgFiles, core.FileAttachment{
MimeType: im.MimeType,
Data: im.Data,
FileName: name,
})
}
imagePaths := core.SaveFilesToDisk(cs.workDir, messageID, imgFiles)
prompt = core.AppendImageRefs(prompt, imagePaths)
}
if len(files) > 0 {
filePaths := core.SaveFilesToDisk(cs.workDir, messageID, files)
prompt = core.AppendFileRefs(prompt, filePaths)
}
if !cs.alive.Load() {
return fmt.Errorf("session is closed")
}
chatID := cs.CurrentSessionID()
isResume := chatID != ""
args := append(append([]string{}, cs.extraArgs...),
"--print",
"--output-format", "stream-json",
)
switch cs.mode {
case "force":
args = append(args, "--force")
case "plan":
args = append(args, "--mode", "plan")
case "ask":
args = append(args, "--mode", "ask")
}View on GitHub (pinned to 4000b2338a)
Solutions
- Start a new session rather than reusing the closed one
- Avoid sending after teardown (/stop or errors)
- Inspect logs for the closure cause if unexpected
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at agent/cursor/session.go:105 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/837715410ca3ce0e.
Report an issue: GitHub.