Skip to content

Commit 5d5a087

Browse files
committed
[FAB-10284] Fix tx-id race with sending response
Change-Id: I6863621e0f6c9eda47e6d37027f059a4ec3028b6 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent bce5737 commit 5d5a087

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

core/chaincode/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ func (h *Handler) HandleTransaction(msg *pb.ChaincodeMessage, delegate handleFun
249249
}
250250

251251
chaincodeLogger.Debugf("[%s] Completed %s. Sending %s", shorttxid(msg.Txid), msg.Type, resp.Type)
252-
h.serialSendAsync(resp, false)
253252
h.ActiveTransactions.Remove(msg.ChannelId, msg.Txid)
253+
h.serialSendAsync(resp, false)
254254
}
255255

256256
func shorttxid(txid string) string {

core/chaincode/handler_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ var _ = Describe("Handler", func() {
157157
Expect(msg).To(Equal(expectedResponse))
158158
})
159159

160-
It("deregisters the message transaction ID", func() {
160+
It("deregisters the transaction ID before sending the response", func() {
161+
fakeTransactionRegistry.RemoveStub = func(channelID, txID string) {
162+
Consistently(fakeChatStream.SendCallCount).Should(Equal(0))
163+
}
164+
161165
handler.HandleTransaction(incomingMessage, fakeMessageHandler.Handle)
162166

163167
Expect(fakeTransactionRegistry.RemoveCallCount()).To(Equal(1))

0 commit comments

Comments
 (0)