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

WebsocketProvider: Incorrect response when duplicate IDs #1510

Closed
dmihal opened this issue Mar 29, 2018 · 1 comment
Closed

WebsocketProvider: Incorrect response when duplicate IDs #1510

dmihal opened this issue Mar 29, 2018 · 1 comment
Assignees
Labels
1.x 1.0 related issues Enhancement Includes improvements or optimizations Stale Has not received enough activity
Projects

Comments

@dmihal
Copy link

dmihal commented Mar 29, 2018

Summary

The WebsocketProvider stores callbacks by ID, which it then looks up after receiving the response. However, there may be multiple consumers of the WebsocketProvider that are unaware of each other and duplicate IDs, leading to incorrect responses.


Long story

I ran into this issue while building an app using truffle-contract, which comes bundled with it's own version of web3. I also use my own version of web3 for making calls directly.

The problem comes from the two versions of web3 not sharing the same RequestManager, which is responsible for generating ID numbers. This results in duplicate IDs and incorrect responses.

Workaround

This issue can be fixed by generating two different WebsocketProviders, passing one to instances of truffle-contract, and using the other for web3.

Proposed change

ID numbers in the JSONRPC are essentially meaningless. The WebsocketProvider could replace the ID provided in a data payload with a random integer.

@nivida nivida self-assigned this Aug 9, 2018
@nivida nivida added the Enhancement Includes improvements or optimizations label Nov 28, 2018
@nivida nivida added this to To do in 1.0 Nov 28, 2018
@nivida nivida added the 1.x 1.0 related issues label Jun 20, 2019
This was referenced Nov 21, 2019
richard-ramos added a commit to embarklabs/subspace that referenced this issue Mar 4, 2020
* Lerna
* React components extracted to separate package
* Subspace requires a web3 object instead of a provider due to web3/web3.js#1510
* Update react example to use components
@github-actions
Copy link

github-actions bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions

@github-actions github-actions bot added the Stale Has not received enough activity label Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Enhancement Includes improvements or optimizations Stale Has not received enough activity
Projects
No open projects
1.0
  
Backlog
Development

No branches or pull requests

2 participants