chenhg5/cc-connect · error

session.create timeout

Error message

session.create timeout

What it means

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.

Source

Thrown at agent/copilot/session.go:212

}

func (cs *copilotSession) createSession() error {
	_, createCh := cs.rpc.call("session.create", cs.sessionConfig(newCopilotSessionID()))
	select {
	case resp := <-createCh:
		if resp.Error != nil {
			return fmt.Errorf("session.create: %w", resp.Error)
		}
		var result struct {
			SessionID string `json:"sessionId"`
		}
		if err := json.Unmarshal(resp.Result, &result); err != nil {
			return fmt.Errorf("session.create decode: %w", err)
		}
		cs.sessionID.Store(result.SessionID)
		slog.Info("copilotSession: session created", "sessionId", result.SessionID)
	case <-time.After(10 * time.Second):
		return fmt.Errorf("session.create timeout")
	case <-cs.ctx.Done():
		return cs.ctx.Err()
	}
	return nil
}

func (cs *copilotSession) sessionConfig(sessionID string) copilotSessionConfig {
	requestPermission := true
	streaming := true
	includeSubAgentStreaming := true
	enableConfigDiscovery := true
	return copilotSessionConfig{
		SessionID:                      sessionID,
		ClientName:                     "cc-connect",
		Model:                          strings.TrimSpace(cs.model),
		Provider:                       cs.provider,
		RequestPermission:              &requestPermission,
		WorkingDirectory:               cs.workDir,

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Run the Copilot CLI manually once to complete any first-run prompts/auth so it starts non-interactively.
  2. Verify the CLI process actually starts and stays up; check logs for a concurrent 'process exited' error with stderr output.
  3. Retry — cold-start slowness is often transient.
  4. Raise the 10s deadline in agent/copilot/session.go (case <-time.After(10 * time.Second)) for slow hosts.
  5. Check for stdout corruption/blockage (wrapper scripts, missing PTY) preventing the RPC response from arriving.

Example fix

// before: first run blocks on interactive auth prompt
$ cc-connect start  # session.create timeout
// after: pre-authenticate the CLI non-interactively
$ copilot auth login   # or run `copilot` once interactively
$ cc-connect start
Defensive patterns

Strategy: retry

Validate before calling

ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
if err := exec.CommandContext(ctx, cliPath, "--version").Run(); err != nil {
    return fmt.Errorf("copilot CLI does not start in time: %w", err)
}

Try / catch

err := agent.StartSession(ctx, opts)
if err != nil && strings.Contains(err.Error(), "session.create timeout") {
    // one retry; then surface with CLI stderr diagnostics
    if retryErr := agent.StartSession(ctx, opts); retryErr != nil {
        return fmt.Errorf("session start failed twice: %v / %v", err, retryErr)
    }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/839167e0b2114cb7. Report an issue: GitHub.