mirror of
https://github.com/status-im/nim-ethers.git
synced 2025-01-12 08:34:43 +00:00
only restart on specific errors
This commit is contained in:
parent
022b97b5ce
commit
a64235dfee
@ -202,10 +202,19 @@ proc new*(_: type JsonRpcSubscriptions,
|
|||||||
proc keepAlivePolling =
|
proc keepAlivePolling =
|
||||||
subscriptions.polling = poll()
|
subscriptions.polling = poll()
|
||||||
subscriptions.polling.catch(proc(e: ref CatchableError) =
|
subscriptions.polling.catch(proc(e: ref CatchableError) =
|
||||||
trace "subscription polling loop failed, restarting", error = e.msg
|
# ignore CancelledError, no need to bubble it
|
||||||
startPolling()
|
if e of RpcPostError:
|
||||||
|
discard sleepAsync(pollingInterval).then(proc() =
|
||||||
|
trace "restarting subscription polling loop"
|
||||||
|
subscriptions.polling = nil # release
|
||||||
|
keepAlivePolling()
|
||||||
trace "subscription polling loop restarted"
|
trace "subscription polling loop restarted"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
# What should we do here?
|
||||||
|
fatal "polling loop has failed", error = e.msg
|
||||||
|
raise newException(Defect, "polling loop has failed")
|
||||||
|
)
|
||||||
|
|
||||||
keepAlivePolling()
|
keepAlivePolling()
|
||||||
subscriptions
|
subscriptions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user