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

Autorestart watch_transactions #703

Open
yuriescl opened this issue Aug 28, 2023 · 1 comment
Open

Autorestart watch_transactions #703

yuriescl opened this issue Aug 28, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@yuriescl
Copy link
Contributor

Sometimes when there's a network connection issue between the Anchor and horizon, the watch_transaction script crashes due to an exception:

File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/app/.venv/lib/python3.10/site-packages/polaris/management/commands/watch_transactions.py", line 77, in watch_transactions
    await asyncio.gather(
  File "/home/app/.venv/lib/python3.10/site-packages/polaris/management/commands/watch_transactions.py", line 117, in _for_account
    async for response in endpoint.stream():
  File "/home/app/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 954, in asend
    value = await self.__wrapped.asend(obj)
  File "/home/app/.venv/lib/python3.10/site-packages/stellar_sdk/call_builder/call_builder_async/base_call_builder.py", line 69, in stream
    yield await stream.__anext__()
  File "/home/app/.venv/lib/python3.10/site-packages/typeguard/__init__.py", line 954, in asend
    value = await self.__wrapped.asend(obj)
  File "/home/app/.venv/lib/python3.10/site-packages/stellar_sdk/client/aiohttp_client.py", line 217, in stream
    raise StreamClientError(
stellar_sdk.exceptions.StreamClientError: Failed to get stream message.

But once watch_transaction crashes, it doesn't start automatically and requires manual intervention. At the moment the Anchor has to setup some kind of watcher to restart the script automatically, but this is not ideal, Anchor should not need to worry about this.

Polaris should handle those network crashes gracefully by either restarting the stream automatically.

@yuriescl yuriescl added the bug Something isn't working label Aug 28, 2023
@yuriescl yuriescl changed the title Autorestart watch_transaction Autorestart watch_transactions Aug 28, 2023
@JakeUrban
Copy link
Contributor

I think this makes sense. We'll add a WARN-level log message when the stream is restarted due this error.

@JakeUrban JakeUrban self-assigned this Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants