Skip to content

[Bug]: one SQS message is deleted multiple times in sqs_queue_notification_worker.rb #7747

@your-diary

Description

@your-diary

Expected behavior

a message should be tried to be deleted once regardless of the number of registered handlers

Actual behavior

a message is deleted multiple times when multiple handlers are registered

Steps to reproduce

sqs_client.delete_message() is called inside the @handlers.each loop.

So, when multiple handlers are registered, a message is tried to be deleted that multiple times.

sqs_messages.each do |sqs_message|
  notification = JSON.parse(JSON.parse(sqs_message[:body])['Message'])
  @handlers.each do |handler|
    handler.call(notification)
    sqs_client.delete_message(queue_url: @queue_url, receipt_handle: sqs_message[:receipt_handle])
  end
end

Logs / stacktrace (if applicable)

Which SDK were you using?

Ruby

Which OS were you using?

macOS

SDK version

No response

OS version

No response

Metadata

Metadata

Assignees

Labels

BugAn update to fix incorrect code or typos.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions