chenhg5/cc-connect · error
max: platform stopped
Error message
max: platform stopped
What it means
Start refuses to start the platform if p.stopping is set, i.e. the platform is in the middle of shutting down. This guards against racing a Start call against Stop and returning a half-started platform.
Source
Thrown at platform/max/max.go:159
allowFrom: allowFrom,
webhookURL: webhookURL,
webhookListen: webhookListen,
webhookPath: webhookPath,
webhookSecret: webhookSecret,
resubscribeInterval: resubscribeInterval,
client: &http.Client{Timeout: httpTimeout},
uploadClient: &http.Client{Timeout: attachmentUploadTO},
}, nil
}
func (p *Platform) Name() string { return "max" }
func (p *Platform) Start(handler core.MessageHandler) error {
p.mu.Lock()
defer p.mu.Unlock()
if p.stopping {
return fmt.Errorf("max: platform stopped")
}
p.handler = handler
ctx, cancel := context.WithCancel(context.Background())
p.ctx = ctx
p.cancel = cancel
// Verify token at startup
if name, id, err := p.getMe(ctx); err != nil {
slog.Warn("max: could not verify bot token", "error", err)
} else {
slog.Info("max: connected", "bot", name, "id", id)
}
if p.webhookURL != "" {
if err := p.startWebhook(ctx); err != nil {
cancel()
return fmt.Errorf("max: start webhook: %w", err)View on GitHub (pinned to 4000b2338a)
Solutions
- Create a fresh Platform via New() and call Start on it instead of reusing a stopped instance.
- Ensure Stop() fully completes before calling Start, e.g. wait for Stop's goroutine/WaitGroup.
- Add synchronization so Start and Stop cannot run concurrently on the same instance.
Example fix
// before p.Stop() p.Start(handler) // error: platform stopped // after p.Stop() p = max.New(opts) p.Start(handler)
Defensive patterns
Strategy: try-catch
Validate before calling
if p.isStopped() { return errors.New("platform already stopped; create a new instance") } Try / catch
if err := p.Start(handler); err != nil {
if strings.Contains(err.Error(), "platform stopped") {
p = max.New(opts)
err = p.Start(handler)
}
} Prevention
- Never call Start after Stop on the same instance; create a new Platform
- Serialize lifecycle transitions with a mutex or state machine
- Await Stop completion before any restart logic
When it happens
Trigger: Calling Start(handler) after Stop() has been called (or while Stop is still running) on the same *Platform instance.
Common situations: Restart logic that reuses the old Platform object instead of constructing a new one via New; lifecycle races between a shutdown signal handler and a reconnect loop calling Start concurrently.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- antigravity: permission request %q is already resolved
- session is closed
- tmux: session %q does not exist and auto_create is disabled
- tmux: create window %q in session %q: %w
- weixin: platform stopped
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/629319515e38d1b9.
Report an issue: GitHub.