Messages pushed to SQS DLQ not visible immediately even with 0 DelaySeconds attribute for DLQ

Expected behavior

Once we have consumed a message from an SQS queue upto its maxReceiveCount and not acknowledged its receipt by deleting it from the queue, the message should be pushed to its DLQ. If the DLQ has a DelaySeconds of 0 seconds(Default) then the message should be immediately available for consumption

Behavior in test

Code should be able to read message from DLQ immediately after it is verified that the condition for DLQ(maxReceiveCount reached) has been met. Though with the current test, reading message from DLQ returns no messages. But after reading the message from DLQ through AWS CLI, the message is visible. This points to the fact that the DelaySeconds attribute is not enforced. This can be either an issue on AWS side which is reflected on Localstack or an issue on the Localstack.

AWS SQS queue creation

echo "Init localstack sqs"

export AWS_DEFAULT_REGION=us-east-1

# For demo purposes, let us create a dead letter queue as well
awslocal sqs --endpoint-url "http://localhost:44566" create-queue --queue-name sample-queue-dlq --attributes '{"MessageRetentionPeriod": "259200", "DelaySeconds": "0"}'

awslocal sqs --endpoint-url "http://localhost:44566" create-queue --queue-name sample-queue --attributes '{"RedrivePolicy": "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:000000000000:sample-queue-dlq\",\"maxReceiveCount\":\"3\"}", "VisibilityTimeout": "1"}'

Steps to reproduce

Code repository: GitHub - varunu28/sqs-dlq-demo
Test file:

For anyone that lands on this issue, please refer bug: SQS - messages only moved to dead letter queue on subsequent RecieveMessageRequest · Issue #8234 · localstack/localstack · GitHub

TL;DR: What you are expecting is correct. The incorrect behavior is introduced due to an optimization on AWS end.