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

Better handle or bubble up RPC errors #156

Open
wphan opened this issue Apr 11, 2024 · 1 comment
Open

Better handle or bubble up RPC errors #156

wphan opened this issue Apr 11, 2024 · 1 comment

Comments

@wphan
Copy link
Member

wphan commented Apr 11, 2024

Account subscribers sometimes see unhelpful errors like this:

Traceback (most recent call last):
  File "/example/drift_sdk.py", line 75, in <module>
    asyncio.run(main())
  File "/Users/ww/.pyenv/versions/3.10.11/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/ww/.pyenv/versions/3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/example/drift_sdk.py", line 46, in main
    await dc.subscribe()
  File "/example/drift_client.py", line 167, in subscribe
    await self.account_subscriber.subscribe()
  File "/example/venv/lib/python3.10/site-packages/driftpy/accounts/ws/drift_client.py", line 71, in subscribe
    ) = await find_all_market_and_oracles(self.program, data_and_slots=True)
  File "/example/venv/lib/python3.10/site-packages/driftpy/constants/config.py", line 142, in find_all_market_and_oracles
    perp_slot = int(parsed_resp.result["context"]["slot"])
AttributeError: 'Error' object has no attribute 'result'

if we dig in and print resp when it has no result, it's actually an RPC error:

Error(code=429, message='Too many requests for a specific RPC call, contact your app developer or [email protected].', data=None, id=1)
@wphan
Copy link
Member Author

wphan commented Apr 11, 2024

silently failing like this leads to really confusing user experience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant