diff --git a/server/client.go b/server/client.go index cccbc218..495276fb 100644 --- a/server/client.go +++ b/server/client.go @@ -4103,16 +4103,14 @@ func (c *client) processMsgResults(acc *Account, r *SublistResult, msg, deliver, // Check for JetStream encoded reply subjects. // For now these will only be on $JS.ACK prefixed reply subjects. + var remapped bool if len(creply) > 0 && c.kind != CLIENT && c.kind != SYSTEM && c.kind != JETSTREAM && c.kind != ACCOUNT && bytes.HasPrefix(creply, []byte(jsAckPre)) { // We need to rewrite the subject and the reply. if li := bytes.LastIndex(creply, []byte("@")); li != -1 && li < len(creply)-1 { + remapped = true subj, creply = creply[li+1:], creply[:li] - // Make sure deliver is set if inbound from a route. - if c.kind == ROUTER { - deliver = subj - } } } @@ -4166,6 +4164,10 @@ func (c *client) processMsgResults(acc *Account, r *SublistResult, msg, deliver, dsubj = append(_dsubj[:0], sub.im.to...) } + // Make sure deliver is set if inbound from a route. + if remapped && c.kind == ROUTER { + deliver = subj + } // If we are mapping for a deliver subject we will reverse roles. // The original subj we set from above is correct for the msg header, // but we need to transform the deliver subject to properly route. diff --git a/server/jetstream_cluster_test.go b/server/jetstream_cluster_test.go index ca67dd87..bb123a5c 100644 --- a/server/jetstream_cluster_test.go +++ b/server/jetstream_cluster_test.go @@ -6695,7 +6695,7 @@ func TestJetStreamClusterSingleLeafNodeWithoutSharedSystemAccount(t *testing.T) t.Fatalf("Unexpected publish error: %v", err) } // Make sure the message arrives in our mirror. - checkFor(t, 2*time.Second, 100*time.Millisecond, func() error { + checkFor(t, 5*time.Second, 100*time.Millisecond, func() error { si, err := jsLocal.StreamInfo("M") if err != nil { return fmt.Errorf("Could not get stream info: %v", err)