fix: cancel

This commit is contained in:
Richard Ramos 2024-05-31 15:24:18 -04:00
parent 6faafdbd70
commit e640fe3292
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

View File

@ -330,7 +330,9 @@ func retrieveHistory(ctx context.Context, runId string, storenodes []peer.AddrIn
nextRetryLbl:
for i := 0; i < maxAttempts; i++ {
queryLogger.Info("retrieving next page", zap.String("cursor", hex.EncodeToString(result.Cursor())))
err = result.Next(ctx)
tCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
err = result.Next(tCtx)
cancel()
if err != nil {
queryLogger.Error("could not query storenode", zap.String("cursor", hex.EncodeToString(result.Cursor())), zap.Error(err))
storeNodeFailure = true
@ -373,7 +375,9 @@ func verifyMessageExistence(ctx context.Context, runId string, peerID peer.ID, m
queryLbl:
for i := 0; i < maxAttempts; i++ {
queryLogger.Info("querying by hash", zap.Int("attempt", i))
result, err = wakuNode.Store().QueryByHash(ctx, messageHashes, store.IncludeData(false), store.WithPeer(peerInfo.ID), store.WithPaging(false, 100))
tCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
result, err = wakuNode.Store().QueryByHash(tCtx, messageHashes, store.IncludeData(false), store.WithPeer(peerInfo.ID), store.WithPaging(false, 100))
cancel()
if err != nil {
queryLogger.Error("could not query storenode", zap.Error(err), zap.Int("attempt", i))
storeNodeFailure = true
@ -417,7 +421,9 @@ queryLbl:
nextRetryLbl:
for i := 0; i < maxAttempts; i++ {
queryLogger.Info("executing next while querying hashes", zap.String("cursor", hexutil.Encode(result.Cursor())), zap.Int("attempt", i))
err = result.Next(ctx)
tCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
err = result.Next(tCtx)
cancel()
if err != nil {
queryLogger.Error("could not query storenode", zap.String("cursor", hexutil.Encode(result.Cursor())), zap.Error(err), zap.Int("attempt", i))
storeNodeFailure = true