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

fix: ws errors should conform to jsonrpc spec #2505

Conversation

ted-yeh-vc
Copy link
Contributor

Description:

This PR fixes the error returned from websockets being closed to be conformant to json rpc spec re: errors.
https://www.jsonrpc.org/specification#error_object
Related issue(s):

Fixes #2362

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@ted-yeh-vc
Copy link
Contributor Author

I could be in the wrong, but it seems unnecessary to push an error to the client before closing the connection. The connection closing has its own code and message. Was there a particular reason the separate message is being sent?

@quiet-node
Copy link
Member

I could be in the wrong, but it seems unnecessary to push an error to the client before closing the connection. The connection closing has its own code and message. Was there a particular reason the separate message is being sent?

Hi @ted-yeh-vc thanks for poiniting it out! You're right the closing connection has its own code and message, when I pushed in the update I thought it could make it a little more informative for some users by informing them the error before closing the connection. Just a little slight touch on the UX. I will discuss with the team and get back to you later!

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

So, I discussed with my team and we decided to keep the current layout with the extra piece of message sent back to the client. Also, we aggreed that your approach to make the error conform to jsonrpc spec is necessary, and we want the errors to have a consistent structure. Please find the change suggestion below for the new structure. Thanks a lot for the time and effort!

packages/ws-server/src/metrics/connectionLimiter.ts Outdated Show resolved Hide resolved
packages/ws-server/src/metrics/connectionLimiter.ts Outdated Show resolved Hide resolved
packages/ws-server/src/metrics/connectionLimiter.ts Outdated Show resolved Hide resolved
ted-yeh-vc and others added 3 commits May 21, 2024 10:19
@ted-yeh-vc
Copy link
Contributor Author

Fantastic. Thanks for the quick review. Always happy to help!

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

LGTM

@quiet-node
Copy link
Member

@ted-yeh-vc looks like the first commit didn't get verified. Please fix it for the PR to be mergable.

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LGTM

@quiet-node quiet-node added the enhancement New feature or request label May 23, 2024
@quiet-node quiet-node added this to the 0.49.0 milestone May 23, 2024
@quiet-node quiet-node merged commit c4dac63 into hashgraph:main May 23, 2024
31 of 32 checks passed
@ted-yeh-vc ted-yeh-vc deleted the 2362-ws-errors-should-conform-to-jsonrpc-spec branch May 28, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WS server limiter close connection at max limit wihtout sending the reason back to clients
3 participants