From 96072d66f0630dc854f5aca3a4c7d05c2bf79ccd Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Thu, 29 Apr 2021 07:08:21 -0700 Subject: [PATCH] Internal JetStream callbacks for message delivery across GWs could lose responses. For internal callbacks we can not rely on the GW routed reply tracking since internal clients can change who receives vs sends response. Signed-off-by: Derek Collison --- server/client.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/client.go b/server/client.go index 802b5d37..73796703 100644 --- a/server/client.go +++ b/server/client.go @@ -3058,20 +3058,22 @@ func (c *client) deliverMsg(sub *subscription, subject, reply, mh, msg []byte, g // Check for internal subscriptions. if sub.icb != nil && !c.noIcb { - if gwrply { - // Note that we keep track of the GW routed reply in the destination - // connection (`client`). The routed reply subject is in `c.pa.reply`, - // should that change, we would have to pass the GW routed reply as - // a parameter of deliverMsg(). - srv.trackGWReply(client, c.pa.reply) + ireply := string(reply) + // For internal callbacks we don't want to rely on the GW routed reply tracking + // since clients can change for who receives vs sends response. GW routed + // currently pins to a destination client connection. Also for internal its + // ok if we do not hide the raw reply like we do for external clients. We + // will not remap service import replies since they are handled different. + if gwrply && !isServiceReply(reply) { + ireply = string(c.pa.reply) } client.mu.Unlock() // Internal account clients are for service imports and need the '\r\n'. if client.kind == ACCOUNT { - sub.icb(sub, c, string(subject), string(reply), msg) + sub.icb(sub, c, string(subject), ireply, msg) } else { - sub.icb(sub, c, string(subject), string(reply), msg[:msgSize]) + sub.icb(sub, c, string(subject), ireply, msg[:msgSize]) } return true }