Skip to content

Commit

Permalink
fix race condition in test
Browse files Browse the repository at this point in the history
credit to @robert-zaremba
  • Loading branch information
yihuang committed Jul 19, 2021
1 parent 6576c72 commit ab27b1c
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions testutil/network/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,10 @@ func startInProcess(cfg Config, val *Validator) error {
val.grpc = grpcSrv

if val.AppConfig.GRPCWeb.Enable {
errCh1 := make(chan error)
go func() {
grpcWeb, err := servergrpc.StartGRPCWeb(grpcSrv, *val.AppConfig)
if err != nil {
errCh1 <- err
}

val.grpcWeb = grpcWeb
}()
select {
case err := <-errCh1:
val.grpcWeb, err = servergrpc.StartGRPCWeb(grpcSrv, *val.AppConfig)
if err != nil {
return err
case <-time.After(srvtypes.ServerStartTime): // assume server started successfully
}

}
}

Expand Down

0 comments on commit ab27b1c

Please sign in to comment.