{"record":{"id":"839167e0b2114cb7","repo":"chenhg5/cc-connect","slug":"session-create-timeout","errorCode":null,"errorMessage":"session.create timeout","messagePattern":"session\\.create timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/copilot/session.go","lineNumber":212,"sourceCode":"}\n\nfunc (cs *copilotSession) createSession() error {\n\t_, createCh := cs.rpc.call(\"session.create\", cs.sessionConfig(newCopilotSessionID()))\n\tselect {\n\tcase resp := <-createCh:\n\t\tif resp.Error != nil {\n\t\t\treturn fmt.Errorf(\"session.create: %w\", resp.Error)\n\t\t}\n\t\tvar result struct {\n\t\t\tSessionID string `json:\"sessionId\"`\n\t\t}\n\t\tif err := json.Unmarshal(resp.Result, &result); err != nil {\n\t\t\treturn fmt.Errorf(\"session.create decode: %w\", err)\n\t\t}\n\t\tcs.sessionID.Store(result.SessionID)\n\t\tslog.Info(\"copilotSession: session created\", \"sessionId\", result.SessionID)\n\tcase <-time.After(10 * time.Second):\n\t\treturn fmt.Errorf(\"session.create timeout\")\n\tcase <-cs.ctx.Done():\n\t\treturn cs.ctx.Err()\n\t}\n\treturn nil\n}\n\nfunc (cs *copilotSession) sessionConfig(sessionID string) copilotSessionConfig {\n\trequestPermission := true\n\tstreaming := true\n\tincludeSubAgentStreaming := true\n\tenableConfigDiscovery := true\n\treturn copilotSessionConfig{\n\t\tSessionID:                      sessionID,\n\t\tClientName:                     \"cc-connect\",\n\t\tModel:                          strings.TrimSpace(cs.model),\n\t\tProvider:                       cs.provider,\n\t\tRequestPermission:              &requestPermission,\n\t\tWorkingDirectory:               cs.workDir,","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/copilot/session.go#L194-L230","documentation":"If the Copilot CLI process never answers the 'session.create' JSON-RPC request within 10 seconds, createSession gives up and returns 'session.create timeout'. Like the resume timeout, this prevents an unresponsive child process from blocking session startup indefinitely.","triggerScenarios":"handshake -> createSession -> cs.rpc.call(\"session.create\", ...) and the select hits case <-time.After(10*time.Second) because the CLI never writes a response to stdout (hung startup, blocked stdin write, deadlocked CLI, readLoop not consuming stdout).","commonSituations":"CLI binary hangs waiting for interactive input (first-run prompts, TOS acceptance); extremely slow start on constrained hosts; CLI crashed before replying (see 'process exited' in logs); stdout not being drained because the reader goroutine failed.","solutions":["Run the Copilot CLI manually once to complete any first-run prompts/auth so it starts non-interactively.","Verify the CLI process actually starts and stays up; check logs for a concurrent 'process exited' error with stderr output.","Retry — cold-start slowness is often transient.","Raise the 10s deadline in agent/copilot/session.go (case <-time.After(10 * time.Second)) for slow hosts.","Check for stdout corruption/blockage (wrapper scripts, missing PTY) preventing the RPC response from arriving."],"exampleFix":"// before: first run blocks on interactive auth prompt\n$ cc-connect start  # session.create timeout\n// after: pre-authenticate the CLI non-interactively\n$ copilot auth login   # or run `copilot` once interactively\n$ cc-connect start","handlingStrategy":"retry","validationCode":"ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\ndefer cancel()\nif err := exec.CommandContext(ctx, cliPath, \"--version\").Run(); err != nil {\n    return fmt.Errorf(\"copilot CLI does not start in time: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := agent.StartSession(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"session.create timeout\") {\n    // one retry; then surface with CLI stderr diagnostics\n    if retryErr := agent.StartSession(ctx, opts); retryErr != nil {\n        return fmt.Errorf(\"session start failed twice: %v / %v\", err, retryErr)\n    }\n}","preventionTips":["Complete CLI first-run prompts/auth interactively before daemonized use","Provision enough CPU/memory so the CLI starts well under 10s","Retry once on timeout; cold starts are often transient","Check for a concurrent 'process exited' log indicating the CLI crashed instead of timing out"],"tags":["timeout","rpc","session-lifecycle","process-management"],"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"}