sipeed/picoclaw · error

reload already in progress

Error message

reload already in progress

What it means

Returned by the manual /reload trigger when the atomic reloading flag is already set: a reload is currently executing, so this request is rejected rather than queued. Guarded by a CompareAndSwap, so it is a concurrency guard, not a config problem.

Solutions

  1. Wait for the in-flight reload to finish, then trigger reload again
  2. Check the gateway log for the running reload's progress or failure
  3. Avoid hammering the /reload endpoint; it permits only one reload at a time
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/gateway/gateway.go:232 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/88afdc1a407e57f8. Report an issue: GitHub.

Appendix: source

Thrown at pkg/gateway/gateway.go:232

	runningServices, err := setupAndStartServices(cfg, agentLoop, msgBus, pidData.Token, listenResult)
	if err != nil {
		return err
	}
	// All services (channels + shared HTTP server) are up; mark the health
	// server ready so GET /ready reports "ready". The health endpoints are
	// mounted on the shared gateway mux, so Health.Server.Start() (which would
	// otherwise set this) is never called — we flip the flag explicitly here.
	runningServices.HealthServer.SetReady(true)
	publishGatewayEvent(agentLoop, runtimeevents.KindGatewayReady, startedAt, nil)
	closeListeners = false

	// Setup manual reload channel for /reload endpoint
	manualReloadChan := make(chan struct{}, 1)
	runningServices.manualReloadChan = manualReloadChan
	reloadTrigger := func() error {
		if !runningServices.reloading.CompareAndSwap(false, true) {
			return fmt.Errorf("reload already in progress")
		}
		select {
		case manualReloadChan <- struct{}{}:
			return nil
		default:
			// Should not happen, but reset flag if channel is full
			runningServices.reloading.Store(false)
			return fmt.Errorf("reload already queued")
		}
	}
	runningServices.HealthServer.SetReloadFunc(reloadTrigger)
	agentLoop.SetReloadFunc(reloadTrigger)

	for _, bindHost := range listenResult.BindHosts {
		fmt.Printf("✓ Gateway started on %s\n", net.JoinHostPort(bindHost, strconv.Itoa(cfg.Gateway.Port)))
	}
	fmt.Println("Press Ctrl+C to stop")

View on GitHub (pinned to 49183d7e8d)