{"record":{"id":"88afdc1a407e57f8","repo":"sipeed/picoclaw","slug":"reload-already-in-progress","errorCode":null,"errorMessage":"reload already in progress","messagePattern":"reload already in progress","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/gateway/gateway.go","lineNumber":232,"sourceCode":"\n\trunningServices, err := setupAndStartServices(cfg, agentLoop, msgBus, pidData.Token, listenResult)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// All services (channels + shared HTTP server) are up; mark the health\n\t// server ready so GET /ready reports \"ready\". The health endpoints are\n\t// mounted on the shared gateway mux, so Health.Server.Start() (which would\n\t// otherwise set this) is never called — we flip the flag explicitly here.\n\trunningServices.HealthServer.SetReady(true)\n\tpublishGatewayEvent(agentLoop, runtimeevents.KindGatewayReady, startedAt, nil)\n\tcloseListeners = false\n\n\t// Setup manual reload channel for /reload endpoint\n\tmanualReloadChan := make(chan struct{}, 1)\n\trunningServices.manualReloadChan = manualReloadChan\n\treloadTrigger := func() error {\n\t\tif !runningServices.reloading.CompareAndSwap(false, true) {\n\t\t\treturn fmt.Errorf(\"reload already in progress\")\n\t\t}\n\t\tselect {\n\t\tcase manualReloadChan <- struct{}{}:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\t// Should not happen, but reset flag if channel is full\n\t\t\trunningServices.reloading.Store(false)\n\t\t\treturn fmt.Errorf(\"reload already queued\")\n\t\t}\n\t}\n\trunningServices.HealthServer.SetReloadFunc(reloadTrigger)\n\tagentLoop.SetReloadFunc(reloadTrigger)\n\n\tfor _, bindHost := range listenResult.BindHosts {\n\t\tfmt.Printf(\"✓ Gateway started on %s\\n\", net.JoinHostPort(bindHost, strconv.Itoa(cfg.Gateway.Port)))\n\t}\n\tfmt.Println(\"Press Ctrl+C to stop\")\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/gateway/gateway.go#L214-L250","documentation":"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.","triggerScenarios":"Thrown at pkg/gateway/gateway.go:232 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the in-flight reload to finish, then trigger reload again","Check the gateway log for the running reload's progress or failure","Avoid hammering the /reload endpoint; it permits only one reload at a time"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}