chenhg5/cc-connect · error

ping: %w

Error message

ping: %w

What it means

Handshake step 1 sends the JSON-RPC `ping` request to the copilot process. If the process replies with a JSON-RPC error object, it is surfaced as "ping: %w". The session is functional at the transport level but the CLI refused the ping — usually an authentication, version, or internal CLI problem.

Source

Thrown at agent/copilot/session.go:165

	// Start reading loop
	go cs.readLoop(&stderrBuf)

	// Perform handshake: ping then create/resume session
	if err := cs.handshake(resumeSessionID); err != nil {
		_ = cs.Close()
		return nil, fmt.Errorf("copilotSession: handshake failed: %w", err)
	}

	return cs, nil
}

func (cs *copilotSession) handshake(resumeSessionID string) error {
	// Step 1: Ping
	_, pingCh := cs.rpc.call("ping", nil)
	select {
	case resp := <-pingCh:
		if resp.Error != nil {
			return fmt.Errorf("ping: %w", resp.Error)
		}
		slog.Debug("copilotSession: ping OK")
	case <-time.After(10 * time.Second):
		return fmt.Errorf("ping timeout")
	case <-cs.ctx.Done():
		return cs.ctx.Err()
	}

	// Step 2: Create or resume session
	if resumeSessionID != "" && resumeSessionID != core.ContinueSession {
		_, resumeCh := cs.rpc.call("session.resume", cs.sessionConfig(resumeSessionID))
		select {
		case resp := <-resumeCh:
			if resp.Error != nil {
				slog.Warn("copilotSession: resume failed, creating new session", "error", resp.Error)
				return cs.createSession()
			}
			cs.sessionID.Store(resumeSessionID)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the wrapped JSON-RPC error message/data for the exact reason the CLI rejected ping
  2. Re-authenticate: run `copilot auth login` (or equivalent) as the daemon user
  3. Update the copilot CLI to a version that supports the ping method
  4. If the CLI requires an initialize step first, ensure the handshake order matches the CLI's protocol version
Defensive patterns

Strategy: try-catch

Try / catch

sess, err := StartSession(ctx, cfg, resumeID)
if err != nil {
    var rpcErr interface{ Error() string }
    if strings.Contains(err.Error(), "ping:") {
        // JSON-RPC error from the CLI — usually auth/version; surface inner message
        slog.Error("copilot: ping rejected", "cause", err)
        return fmt.Errorf("copilot unavailable: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: handshake() called from newCopilotSession: rpc.call("ping", nil) completes but resp.Error != nil — the copilot CLI returned an error result for the ping method (e.g. not initialized, unauthorized, method unsupported).

Common situations: Older copilot CLI versions without ping support; CLI requiring initialization before accepting requests; expired Copilot authentication; CLI reporting an internal error on startup.

Related errors


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