Skip to content

Commit

Permalink
chore: more grpc err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Jul 23, 2024
1 parent d47aa33 commit 7f3abac
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions systest/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func layersStream(
) error {
retries := 0
BACKOFF:

meshapi := pb.NewMeshServiceClient(node.PubConn())
layers, err := meshapi.LayerStream(ctx, &pb.LayerStreamRequest{})
if err != nil {
Expand Down Expand Up @@ -323,6 +322,9 @@ func watchTransactionResults(ctx context.Context,
collector func(*pb.TransactionResult) (bool, error),
) {
eg.Go(func() error {
retries := 0
BACKOFF:

api := pb.NewTransactionServiceClient(client.PubConn())
rsts, err := api.StreamResults(ctx, &pb.TransactionResultsRequest{Watch: true})
if err != nil {
Expand All @@ -338,7 +340,12 @@ func watchTransactionResults(ctx context.Context,
zap.Any("status", s),
)
if s.Code() == codes.Unavailable {
return nil
if retries == attempts {
return errors.New("transaction results unavailable")
}
retries++
time.Sleep(retryBackoff)
goto BACKOFF
}
}
if err != nil {
Expand All @@ -359,6 +366,8 @@ func watchProposals(
collector func(*pb.Proposal) (bool, error),
) {
eg.Go(func() error {
retries := 0
BACKOFF:
dbg := pb.NewDebugServiceClient(client.PrivConn())
proposals, err := dbg.ProposalsStream(ctx, &emptypb.Empty{})
if err != nil {
Expand All @@ -374,7 +383,12 @@ func watchProposals(
zap.Any("status", s),
)
if s.Code() == codes.Unavailable {
return nil
if retries == attempts {
return errors.New("watch proposals unavailable")
}
retries++
time.Sleep(retryBackoff)
goto BACKOFF
}
}
if err != nil {
Expand Down

0 comments on commit 7f3abac

Please sign in to comment.