Skip to content

Handle websocket errors for dYdX #2499

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

davidsblom
Copy link
Member

Pull Request

Handle websocket errors for dYdX. When an internal error occurs, the websocket is not subscribed to the channel. Hence, the client tries to subscribe again after a delay.

Type of change

Delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested?

Live example

@davidsblom davidsblom marked this pull request as draft April 7, 2025 08:35
@davidsblom davidsblom marked this pull request as ready for review April 7, 2025 08:35
@davidsblom davidsblom requested a review from Copilot April 7, 2025 08:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

nautilus_trader/adapters/dydx/websocket/client.py:203

  • [nitpick] Consider defining the error message prefix as a named constant to improve maintainability and reduce duplication.
and ws_message.message.startswith("Internal error, could not fetch data for subscription:")

@davidsblom davidsblom force-pushed the dydx-handle-internal-errors branch from 823d03f to ac47039 Compare April 7, 2025 08:51
@davidsblom davidsblom requested a review from Copilot April 7, 2025 10:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

nautilus_trader/adapters/dydx/websocket/client.py:203

  • Relying on an exact error message text for detecting internal errors may be brittle. Consider using a constant or dedicated error code to identify this condition for improved maintainability.
and ws_message.message.startswith("Internal error, could not fetch data for subscription:")

nautilus_trader/adapters/dydx/websocket/client.py:420

  • When unsubscribing without specifying a channel_id and multiple subscriptions exist for the channel, the current behavior logs an error and aborts the operation. Consider providing a way to either unsubscribe all subscriptions for that channel or requiring the channel_id explicitly to avoid ambiguity.
if len(self._subscriptions[channel]) > 1:

@cjdsellers
Copy link
Member

Many thanks @davidsblom

Let me know if you find copilot useful, or annoying 😄.

@cjdsellers cjdsellers merged commit c484dad into develop Apr 7, 2025
13 checks passed
@cjdsellers cjdsellers deleted the dydx-handle-internal-errors branch April 7, 2025 10:45
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

Successfully merging this pull request may close these issues.

2 participants