{"record":{"id":"6e0db05236d42d44","repo":"chenhg5/cc-connect","slug":"did-not-respond-within-s","errorCode":null,"errorMessage":"did not respond within %s","messagePattern":"did not respond within (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":4613,"sourceCode":"\tcase <-done:\n\t\tif closeErr != nil {\n\t\t\tslog.Error(\"agent session close reported failure, process may still be running\",\n\t\t\t\t\"session\", sessionKey, \"error\", closeErr)\n\t\t\t// The old process may still hold this conversation open — the\n\t\t\t// next turn must not resume into it.\n\t\t\te.markUnsafeResume(sessionKey)\n\t\t\te.notifySessionCloseFailure(sessionKey, platform, replyCtx, closeErr)\n\t\t\treturn\n\t\t}\n\t\tif elapsed := time.Since(closeStart); elapsed >= slowAgentClose {\n\t\t\tslog.Warn(\"slow agent session close\", \"elapsed\", elapsed, \"session\", sessionKey)\n\t\t}\n\tcase <-time.After(closeTimeout):\n\t\tslog.Error(\"agent session close timed out, abandoning\",\n\t\t\t\"timeout\", closeTimeout, \"session\", sessionKey)\n\t\te.markUnsafeResume(sessionKey)\n\t\te.notifySessionCloseFailure(sessionKey, platform, replyCtx,\n\t\t\tfmt.Errorf(\"did not respond within %s\", closeTimeout))\n\t}\n}\n\n// notifySessionCloseFailure alerts the chat that owned a session when its\n// underlying process could not be confirmed killed. Without this, a stuck\n// process can keep running in the background — still holding the session's\n// credentials — while the user believes /stop (or /new) already ended it.\nfunc (e *Engine) notifySessionCloseFailure(sessionKey string, platform Platform, replyCtx any, cause error) {\n\tif platform == nil || replyCtx == nil {\n\t\tslog.Error(\"agent session close failed and no chat is available to alert\",\n\t\t\t\"session\", sessionKey, \"cause\", cause)\n\t\treturn\n\t}\n\ttext := e.i18n.T(MsgSessionCloseFailed) + fmt.Sprintf(\" (%v)\", cause)\n\tif err := e.waitOutgoing(platform); err != nil {\n\t\tslog.Warn(\"notifySessionCloseFailure: wait outgoing failed\", \"session\", sessionKey, \"error\", err)\n\t}\n\tif err := platform.Send(e.ctx, replyCtx, text); err != nil {","sourceCodeStart":4595,"sourceCodeEnd":4631,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L4595-L4631","documentation":"Sent to notifySessionCloseFailure when Close() on an agent session exceeds closeTimeout and the close is abandoned. The session is marked unsafe-to-resume and the owning chat is alerted, because the underlying process may still be running.","triggerScenarios":"agentSession.Close() blocks longer than closeTimeout (the comment mentions up to 130s hangs); time.After fires before Close returns.","commonSituations":"Agent CLI hangs on shutdown (waiting on child processes, stuck network call); SIGKILL-ignoring process state; resource exhaustion in the agent process.","solutions":["Force-kill the leaked agent process manually (pkill the CLI binary)","Investigate why the agent CLI hangs on Close (child process reaping, stdin/stdout not closing)","Treat the session as unsafe — do not resume it; start a fresh session","Increase closeTimeout if the agent legitimately needs longer, though leaking is the real issue"],"exampleFix":"// before\ncloseTimeout := 10 * time.Second // too short for slow agent teardown\n// after\ncloseTimeout := 130 * time.Second // or handle abandon + pkill path deliberately","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"engine.OnSessionCloseFailure(func(key string, err error) { if strings.Contains(err.Error(), \"did not respond within\") { pkillAgentProcess(key); markSessionUnsafe(key) } })","preventionTips":["Harden agent CLIs to shut down promptly and reap children","Monitor for abandoned processes after close timeouts","Never resume sessions marked unsafe-resume; always start fresh"],"tags":["go","timeout","process"],"backgroundTag":"request-timeout","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"}