fix: improve error messages and channel handling in sendRegistration

- Clarify error message when stream fails before registration sent
- Use two-value receive form to properly detect closed channels
- Better distinguish between closed channel and nil value scenarios
This commit is contained in:
Chris Lu
2025-12-22 17:55:43 -08:00
parent f3376c1af0
commit 06ea831368
+3 -3
View File
@@ -637,7 +637,7 @@ func (c *GrpcAdminClient) sendRegistration(worker *types.WorkerData, streamFaile
case <-time.After(5 * time.Second):
return fmt.Errorf("failed to send registration message: timeout")
case <-streamFailed:
return fmt.Errorf("stream failed while sending registration")
return fmt.Errorf("stream failed before registration message could be sent")
}
// Wait for registration response
@@ -647,8 +647,8 @@ func (c *GrpcAdminClient) sendRegistration(worker *types.WorkerData, streamFaile
for {
select {
case regResp := <-regWait:
if regResp == nil {
case regResp, ok := <-regWait:
if !ok || regResp == nil {
return fmt.Errorf("registration failed: channel closed unexpectedly")
}
if regResp.Success {