fix improper `yield` usage in `el_manager` (#5789)

`yield` is not supported in `{.async.}`. Replace with alternative that
does not leak.
This commit is contained in:
Etan Kissling 2024-01-19 08:18:02 +01:00 committed by GitHub
parent b2c49603ae
commit d6e55ca3d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 11 deletions

View File

@ -583,17 +583,14 @@ proc newWeb3*(engineUrl: EngineApiUrl): Future[Web3] =
proc establishEngineApiConnection*(url: EngineApiUrl):
Future[Result[Web3, string]] {.async.} =
let web3Fut = newWeb3(url)
yield web3Fut or sleepAsync(engineApiConnectionTimeout)
if not web3Fut.completed:
await cancelAndWait(web3Fut)
if web3Fut.failed:
return err "Failed to setup Engine API connection: " & web3Fut.readError.msg
else:
return err "Failed to setup Engine API connection"
else:
return ok web3Fut.read
try:
ok(await newWeb3(url).wait(engineApiConnectionTimeout))
except AsyncTimeoutError:
err "Engine API connection timed out"
except CancelledError as exc:
raise exc
except CatchableError as exc:
err "Engine API connection failed: " & exc.msg
proc tryConnecting(connection: ELConnection): Future[bool] {.async.} =
if connection.isConnected: