Skip to content

Commit 8219931

Browse files
authored
Add GRPC retry to flaky test (#2230)
1 parent 67e8457 commit 8219931

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

internal/util/util.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import (
3939
"google.golang.org/grpc"
4040
"google.golang.org/grpc/credentials/insecure"
4141

42+
emulatorUtils "github.com/onflow/flow-emulator/utils"
43+
4244
"github.com/onflow/flowkit/v2"
4345
"github.com/onflow/flowkit/v2/config"
4446
)
@@ -243,12 +245,16 @@ func NetworkToChainID(network string) (flow.ChainID, error) {
243245
}
244246

245247
// GetChainIDFromHost queries the given host directly to get its chain ID.
248+
// It will retry transient failures with exponential backoff using the emulator's gRPC retry interceptor.
246249
func GetChainIDFromHost(host string) (flowGo.ChainID, error) {
247-
248-
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
250+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
249251
defer cancel()
250252

251-
conn, err := grpc.NewClient(host, grpc.WithTransportCredentials(insecure.NewCredentials()))
253+
conn, err := grpc.NewClient(
254+
host,
255+
grpc.WithTransportCredentials(insecure.NewCredentials()),
256+
emulatorUtils.DefaultGRPCRetryInterceptor(),
257+
)
252258
if err != nil {
253259
return "", fmt.Errorf("failed to connect to %s: %w", host, err)
254260
}

0 commit comments

Comments
 (0)