mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 05:25:35 +00:00
rpc: keep the original subscription "id" field when new RPCs come in (#4493)
This commit is contained in:
@@ -23,6 +23,8 @@ program](https://hackerone.com/tendermint).
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
- [rpc] [\#4493](https://github.com/tendermint/tendermint/pull/4493) Keep the original subscription "id" field when new RPCs come in (@michaelfig)
|
||||
|
||||
- [rpc] [\#4437](https://github.com/tendermint/tendermint/pull/4437) Fix tx_search pagination with ordered results (@erikgrinaker)
|
||||
|
||||
- [rpc] [\#4406](https://github.com/tendermint/tendermint/pull/4406) Fix issue with multiple subscriptions on the websocket (@antho1404)
|
||||
|
||||
@@ -38,6 +38,8 @@ func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Capture the current ID, since it can change in the future.
|
||||
subscriptionID := ctx.JSONReq.ID
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
@@ -46,7 +48,7 @@ func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, er
|
||||
ctx.WSConn.TryWriteRPCResponse(
|
||||
rpctypes.NewRPCSuccessResponse(
|
||||
ctx.WSConn.Codec(),
|
||||
ctx.JSONReq.ID,
|
||||
subscriptionID,
|
||||
resultEvent,
|
||||
))
|
||||
case <-sub.Cancelled():
|
||||
@@ -59,7 +61,7 @@ func Subscribe(ctx *rpctypes.Context, query string) (*ctypes.ResultSubscribe, er
|
||||
}
|
||||
ctx.WSConn.TryWriteRPCResponse(
|
||||
rpctypes.RPCServerError(
|
||||
ctx.JSONReq.ID,
|
||||
subscriptionID,
|
||||
fmt.Errorf("subscription was cancelled (reason: %s)", reason),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user