Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rln-relay): enforce error callback to remove exception raised from retryWrapper #2622

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading