I am having this super weird bug where when I run a function on sls offline my SQS trigger only what I can best describe as sporadically.
There is absolutely no difference in input, it's just that only sometimes it will trigger, most of the time it won't. And I'm clueless what could be the problem.
serverless.yml
provider:
iamRoleStatements:
- Effect: "Allow"
Action:
- "sqs:SendMessage"
- "sqs:ReceiveMessage"
- "sqs:GetQueueAttributes"
Resource: "*"
functions:
retry:
handler: handlers/retry.handler
timeout: 30
reservedConcurrency: 1
events:
- sqs:
batchSize: 1
arn:
Fn::GetAtt:
- AddReferral
- Arn
resources:
Resources:
AddReferral:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "AddReferral"
and in my function
const AWS = require('aws-sdk')
const sqs = new AWS.SQS({ apiVersion: '2012-11-05', region: 'us-east-1' })
await sqs.sendMessage(params).promise()
The absolute weird thing is that it works.. sometimes. It's just so random, does anyone have any idea what might be the cause? Is there a delay, timeout, something like that that prevents it from working consecutively?
Also, fwiw, when I deploy the service, everything seems to work as it should, so it's specifically a local issue with either serverless or serverless-offline.
Same happens with me. If i stop and run
serverless offline start
again it will take the last message.
Same happens with me. If i stop and run
serverless offline start
again it will take the last message.
Yes I have this as well
Hi @sebmor , no clue here, sorry. I'm leaving it open in case someone finds why.
Same issue here. It also seems that the messageId of my SQS message is different when I run serverless-offline-start while the md5OfBody is the same:
Result on sending:
{
"ResponseMetadata": {
"RequestId": "00000000-0000-0000-0000-000000000000"
},
"MD5OfMessageBody": "c4c84af282cc04eab1b3808873a03a7e",
"MD5OfMessageAttributes": "d41d8cd98f00b204e9800998ecf8427e",
"MessageId": "88d0643d-7319-48f4-b34a-795572c8c8d3"
}
Event when received after I restart:
{ Records:
[ { messageId: '0e2ffff1-00f8-4fd7-b452-40202733f378',
receiptHandle:
'0e2ffff1-00f8-4fd7-b452-40202733f378#1ce29864-bd1f-4e6c-9688-915c2f524ff2',
body: '{\n\t"hello": "stuff"\n}',
attributes: undefined,
messageAttributes: undefined,
md5OfBody: 'c4c84af282cc04eab1b3808873a03a7e',
eventSource: 'aws:sqs',
eventSourceARN: [Object],
awsRegion: 'us-west-2' } ] }
feel free to re-open with more information. unlikely a serverless-offline bug.
Most helpful comment
Yes I have this as well