Skip to content

Fix issue with multiple subscriptions#4406

Merged
melekes merged 7 commits intotendermint:masterfrom
mesg-foundation:fix/multi-subscription-ws
Feb 17, 2020
Merged

Fix issue with multiple subscriptions#4406
melekes merged 7 commits intotendermint:masterfrom
mesg-foundation:fix/multi-subscription-ws

Conversation

@antho1404
Copy link
Contributor

Using the WebSocket server, when the same client calls multiple time the subscribe method, only the last subscription receives all the events of the previous ones.

example:

  • subscription1 = tm.event = 'NewBlock'
  • subscription2 = tm.event = 'Tx'

In this case, subscription2 will receive the new blocks but subscription1 will not.

This came from the WebSocket handler that had the declaration of the rpcrequest moved and so overridden for every request and given in the JSONReq client context (so the id of the subscription was not the right one).

This fixes the issue by simply declaring the rpcrequest inside the loop so every request will create a new object without overwriting the previous one.

Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
@codecov-io
Copy link

codecov-io commented Feb 14, 2020

Codecov Report

Merging #4406 into master will decrease coverage by 0.03%.
The diff coverage is 50%.

@@            Coverage Diff             @@
##           master    #4406      +/-   ##
==========================================
- Coverage    65.8%   65.77%   -0.04%     
==========================================
  Files         225      225              
  Lines       19952    19947       -5     
==========================================
- Hits        13130    13120      -10     
  Misses       5770     5770              
- Partials     1052     1057       +5
Impacted Files Coverage Δ
rpc/lib/server/ws_handler.go 34.21% <50%> (ø) ⬆️
crypto/sr25519/pubkey.go 32.14% <0%> (-7.15%) ⬇️
blockchain/v2/routine.go 81.81% <0%> (-6.07%) ⬇️
privval/signer_server.go 95.65% <0%> (-4.35%) ⬇️
privval/signer_endpoint.go 81.08% <0%> (-2.71%) ⬇️
blockchain/v1/reactor.go 81.49% <0%> (-0.36%) ⬇️
consensus/reactor.go 78.77% <0%> (-0.35%) ⬇️
blockchain/v1/peer.go 95.65% <0%> (-0.23%) ⬇️
p2p/pex/pex_reactor.go 84.18% <0%> (ø) ⬆️
consensus/state.go 77.95% <0%> (+0.1%) ⬆️
... and 4 more

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

Good catch 👍 Thank you for the fix 🙏

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>
@melekes
Copy link
Contributor

melekes commented Feb 14, 2020

Could you also add a CHANGELOG_PENDING.md entry?

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>
@melekes melekes merged commit 5ea1ff9 into tendermint:master Feb 17, 2020
@antho1404 antho1404 deleted the fix/multi-subscription-ws branch February 17, 2020 09:35
@NicolasMahe NicolasMahe restored the fix/multi-subscription-ws branch March 25, 2020 10:13
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.

4 participants