chenhg5/cc-connect · error

waiting for ready: %w

Error message

waiting for ready: %w

What it means

Returned by waitForReady when reading the READY dispatch frame fails within the 15s deadline — the Hello/Identify exchange succeeded but the READY event never arrived or the read errored (close, timeout, network drop).

Source

Thrown at platform/qqbot/qqbot.go:767

		"d": map[string]any{
			"token":   fmt.Sprintf("QQBot %s", token),
			"intents": p.intents,
			"shard":   [2]int{0, 1},
		},
	}
	p.wsMu.Lock()
	err := conn.WriteJSON(identify)
	p.wsMu.Unlock()
	return err
}

func (p *Platform) waitForReady(conn *websocket.Conn) error {
	_ = conn.SetReadDeadline(time.Now().Add(15 * time.Second))
	defer func() { _ = conn.SetReadDeadline(time.Time{}) }()

	var msg wsPayload
	if err := conn.ReadJSON(&msg); err != nil {
		return fmt.Errorf("waiting for ready: %w", err)
	}
	if msg.Op != opDispatch || msg.T != "READY" {
		return fmt.Errorf("expected READY event, got op=%d t=%s", msg.Op, msg.T)
	}

	var ready struct {
		SessionID string `json:"session_id"`
	}
	if err := json.Unmarshal(msg.D, &ready); err != nil {
		slog.Warn("qqbot: failed to parse READY payload", "error", err)
	}
	p.sessionID = ready.SessionID
	if msg.S != nil {
		p.lastSeq.Store(*msg.S)
	}

	slog.Info("qqbot: gateway READY", "session_id", p.sessionID)
	return nil

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Retry the connect/identify flow with backoff
  2. Verify the requested intents are valid and authorized for the bot app
  3. Check for another live session with the same credentials that may have invalidated this one
  4. Increase the READY deadline if the network is slow
Defensive patterns

Strategy: retry

Validate before calling

// verify identify payload contains valid token + intents before sending

Try / catch

if err := p.waitForReady(conn); err != nil {
    var netErr net.Error
    if errors.As(err, &netErr) && netErr.Timeout() {
        return retryIdentify()
    }
    return err
}

Prevention

When it happens

Trigger: conn.ReadJSON in waitForReady errors: QQ never sends READY (identify rejected silently), the 15s deadline expires, or the server closes the connection.

Common situations: Invalid intents in the identify payload causing silent rejection; duplicate session invalidation; network instability; QQ incident preventing READY delivery.

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/e04d1c7e4eb01024. Report an issue: GitHub.