# grpc：WithBlock 已弃用，将在未来版本中移除

- **ID:** `go/grpc-dial-deprecated-withblock`
- **领域:** go
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 grpc.WithBlock() 的 grpc.Dial 会阻塞直到连接就绪；该 API 已弃用，推荐使用不阻塞的 grpc.NewClient。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| google.golang.org/grpc 1.63+ | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Use grpc.NewClient and trigger connection lazily:
conn, err := grpc.NewClient(target, opts...)
if err != nil { return err }
// force a connection when needed:
conn.Connect()
conn.WaitForStateChange(ctx, connectivity.Idle)
   ```
2. **** (85% 成功率)
   ```
   If you truly need blocking connect semantics, use a health check RPC:
client := pb.NewHealthClient(conn)
_, err = client.Check(ctx, &pb.HealthCheckRequest{})
   ```

## 无效尝试

- **** — Does not fix the underlying behavior change; WithBlock will be removed and the build will break. (70% 失败率)
- **** — grpc.NewClient rejects WithBlock and returns an error at construction time. (95% 失败率)
