Skip to content

Commit

Permalink
Fix missing return - causing duplicate calls to sendResponse - trigge…
Browse files Browse the repository at this point in the history
…ring a panic (#94)

Fixes #93
  • Loading branch information
nstogner authored Apr 9, 2024
1 parent 26924e9 commit c30fa6e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/messenger/messager.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (m *Messenger) handleRequest(ctx context.Context, msg *pubsub.Message) {
respPayload, respCode, err := m.sendBackendRequest(ctx, url, req.body)
if err != nil {
m.sendResponse(req, m.jsonError("error sending request to backend: %v", err), http.StatusBadGateway)
return
}

m.sendResponse(req, respPayload, respCode)
Expand Down Expand Up @@ -290,7 +291,7 @@ func (m *Messenger) sendResponse(req *request, body []byte, statusCode int) {
log.Printf("Error sending response for message %s: %v", req.msg.LoggableID, err)
m.addConsecutiveError()

// If a repsonse cant be sent, the message should be redelivered.
// If a response cant be sent, the message should be redelivered.
if req.msg.Nackable() {
req.msg.Nack()
}
Expand Down

0 comments on commit c30fa6e

Please sign in to comment.