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

web3-provider: Use an incremental JSONRPC id instead of 42 #337

Closed
shazow opened this issue Nov 7, 2018 · 4 comments
Closed

web3-provider: Use an incremental JSONRPC id instead of 42 #337

shazow opened this issue Nov 7, 2018 · 4 comments
Labels
discussion Questions, feedback and general information.

Comments

@shazow
Copy link

shazow commented Nov 7, 2018

Re:

I realize that this mostly works right now, but it's just one more line to add an incremental id and it would help with identifying different messages while trying to debug what's going on.

Something like:

let _counter = 0;

...
{
    id: _counter++,
    ...
}

Should do the trick.

@ricmoo
Copy link
Member

ricmoo commented Nov 7, 2018

That id should have no effect on your calls, since each call is made within its own TCP connection, there is no multiplexing required, so it makes more sense to keep static.

What problem are you experiencing? You mean on the server side you are trying to parse the request? A better solution is to extend and override for a DebugProvider, which performs the console.log.

Soon, the WebSocketProvider will be ready, which will update the id, since all calls and subscriptions are multiplexed...

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Nov 7, 2018
@shazow
Copy link
Author

shazow commented Nov 7, 2018

I do mean it adds more distinction server-side.

I already debugged the problem I was having, but this is a convenience that I don't see a downside to and arguably more in the spirit of the JSONRPC 2.0 spec.

Your call though.

Edit:

since each call is made within its own TCP connection

Is that an actual guarantee? I would have guessed the client-side socket gets reused by default these days.

@ricmoo
Copy link
Member

ricmoo commented May 24, 2019

This has been changed in 4.0.28, to use a globally unique ID to solve some issues with broken clients. Le sigh... :s

Is that an actual guarantee?

Yes, the implementation for JsonRpcProvider implementation always uses a new TCP connection internally.

In the future though, the WebSocketProvider (in progress) will re-use the connection, and will of course use a unique ID within a given connection.

Closing this issue though, since it no longer uses the hard-coded value of 42. :)

@ricmoo ricmoo closed this as completed May 24, 2019
@shazow
Copy link
Author

shazow commented May 24, 2019

🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

2 participants