-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Labels
1.x
1.0 related issues
Enhancement
Includes improvements or optimizations
Stale
Has not received enough activity
Comments
This was referenced Nov 21, 2019
Closed
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
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 |
1 task
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
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.
The text was updated successfully, but these errors were encountered: