Skip to content

Go SDK: Deadlock in client.Start() when starting CLI via stdio #19

@djdefi

Description

@djdefi

Summary

The Go SDK deadlocks when calling client.Start() on macOS. The CLI works correctly when invoked directly, but the SDK's JSON-RPC communication over stdio fails.

Environment

  • OS: macOS (Apple Silicon)
  • Go version: 1.24
  • SDK version: v0.0.0-20260115160841-b8a836b2c6a3 (pseudo-version from main)
  • CLI version: 0.0.354 (Commit: 076bd172b)
  • CLI path: /Users/djdefi/Library/Application Support/Code - Insiders/User/globalStorage/github.copilot-chat/copilotCli/copilot

Steps to Reproduce

package main

import (
    "log"
    copilot "github.com/github/copilot-sdk/go"
)

func main() {
    client := copilot.NewClient(&copilot.ClientOptions{
        LogLevel: "error",
    })
    
    // This deadlocks - never returns
    if err := client.Start(); err != nil {
        log.Fatal(err)
    }
    defer client.Stop()
    
    log.Println("Client started") // Never reached
}

Expected Behavior

client.Start() should either:

  1. Successfully start the CLI and establish JSON-RPC communication
  2. Return an error if communication fails

Actual Behavior

Program deadlocks with:

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [select]:
github.com/github/copilot-sdk/go.(*JSONRPCClient).Request(...)
        jsonrpc.go:147
github.com/github/copilot-sdk/go.(*Client).Ping(...)
        client.go:730
github.com/github/copilot-sdk/go.(*Client).verifyProtocolVersion(...)
        client.go:753
github.com/github/copilot-sdk/go.(*Client).Start(...)
        client.go:239

Working CLI Test

The CLI works correctly when invoked directly:

$ copilot --log-level debug --allow-all-tools -p "hello"
Hello! I'm GitHub Copilot CLI, ready to help you with software engineering tasks...

Analysis

The deadlock occurs in verifyProtocolVersion()Ping()JSONRPCClient.Request(), suggesting the JSON-RPC channel setup over stdio isn't working correctly. The CLI starts but either:

  1. Doesn't output the expected JSON-RPC responses
  2. The SDK isn't reading them correctly
  3. There's a timing issue in the startup sequence

Workaround

Currently using the mock client while investigating. Would appreciate any guidance on:

  1. Required CLI flags for JSON-RPC mode
  2. Environment variables for SDK communication
  3. Alternative TCP mode configuration

Related

This is a follow-up discovery from #18 (Go submodule version tags). Found while trying to integrate the SDK into a project.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions