{"record":{"id":"0e3a4f6a80ce9603","repo":"chenhg5/cc-connect","slug":"session-reset","errorCode":null,"errorMessage":"session reset","messagePattern":"session reset","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"core/engine.go","lineNumber":4315,"sourceCode":"\n\t// Notify senders of any queued messages that will never be processed.\n\tif ok && state != nil {\n\t\t// Stop unsolicited reader before marking stopped to avoid goroutine leak.\n\t\te.stopUnsolicitedReader(state)\n\n\t\tstate.markStopped()\n\n\t\t// Resolve any pending permission so the reader goroutine (or event\n\t\t// loop) does not block on <-pending.Resolved forever.\n\t\tstate.mu.Lock()\n\t\tpending := state.pending\n\t\tstate.pending = nil\n\t\tstate.mu.Unlock()\n\t\tif pending != nil {\n\t\t\tpending.resolve()\n\t\t}\n\n\t\te.notifyDroppedQueuedMessages(state, fmt.Errorf(\"session reset\"))\n\t}\n\n\t// Close the agent session BEFORE deleting from the map.\n\t// This prevents race conditions where /stop during cleanup sees\n\t// an empty map and reports \"No execution in progress\" while\n\t// the agent session Close() is still blocking (up to 130s).\n\tif agentSession != nil {\n\t\te.closeAgentSessionWithTimeout(sessionKey, agentSession, closePlatform, closeReplyCtx)\n\t}\n\n\t// Now delete the state from the map after the session is closed.\n\te.interactiveMu.Lock()\n\t// Re-check that the state hasn't been replaced during the close\n\tcurrentState, currentOk := e.interactiveStates[sessionKey]\n\tif currentOk && len(expected) > 0 && expected[0] != nil && currentState != expected[0] {\n\t\t// Another turn has replaced the state during our close — don't delete it.\n\t\te.interactiveMu.Unlock()\n\t\treturn","sourceCodeStart":4297,"sourceCodeEnd":4333,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L4297-L4333","documentation":"A reason string passed to notifyDroppedQueuedMessages when a session is being reset: queued messages that were never delivered to the agent are dropped and users are notified. Not a failure — expected during /reset or /new flows.","triggerScenarios":"Session reset (e.g. /new command) runs while messages still sit in the session's queue.","commonSituations":"User types /new while the agent is still processing earlier queued prompts; admin resets a stuck session.","solutions":["Inform users that queued prompts are discarded on reset","Wait for queue drain before issuing /new","Re-send the dropped prompt after the new session is ready"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"engine.OnQueuedMessagesDropped(func(key string, reason error) { if strings.Contains(reason.Error(), \"session reset\") { promptUserToResend(key) } })","preventionTips":["Warn users that /new discards queued prompts","Drain the queue before reset when content matters","Re-send important prompts after the new session starts"],"tags":["go","session","reset"],"backgroundTag":"invalid-state-transition","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}