Skip to content

Commit

Permalink
fix(rln-relay): enforce error callback to remove exception raised fro…
Browse files Browse the repository at this point in the history
…m retryWrapper (#2622)
  • Loading branch information
rymnc authored Apr 24, 2024
1 parent b28207a commit 9c9883a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 2 additions & 3 deletions waku/waku_rln_relay/group_manager/on_chain/group_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ proc startOnchainSync(
var currentLatestBlock: BlockNumber
g.retryWrapper(currentLatestBlock, "Failed to get the latest block number"):
cast[BlockNumber](await ethRpc.provider.eth_blockNumber())

try:
# we always want to sync from last processed block => latest
# chunk events
Expand All @@ -646,11 +646,10 @@ proc startOnchainSync(
# then fetch the new toBlock
if fromBlock >= currentLatestBlock:
break

if fromBlock + blockChunkSize.uint > currentLatestBlock.uint:
g.retryWrapper(currentLatestBlock, "Failed to get the latest block number"):
cast[BlockNumber](await ethRpc.provider.eth_blockNumber())


let toBlock = min(fromBlock + BlockNumber(blockChunkSize), currentLatestBlock)
debug "fetching events", fromBlock = fromBlock, toBlock = toBlock
Expand Down
11 changes: 3 additions & 8 deletions waku/waku_rln_relay/group_manager/on_chain/retry_wrapper.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template retryWrapper*(
res: auto,
retryStrategy: RetryStrategy,
errStr: string,
errCallback: OnFatalErrorHandler = nil,
errCallback: OnFatalErrorHandler,
body: untyped,
): auto =
var retryCount = retryStrategy.retryCount
Expand All @@ -29,10 +29,5 @@ template retryWrapper*(
exceptionMessage = getCurrentExceptionMsg()
await sleepAsync(retryStrategy.retryDelay)
if shouldRetry:
if errCallback == nil:
raise newException(
CatchableError, errStr & " errCallback == nil: " & exceptionMessage
)
else:
errCallback(errStr & ": " & exceptionMessage)
return
errCallback(errStr & ": " & exceptionMessage)
return

0 comments on commit 9c9883a

Please sign in to comment.