serverless-plugins icon indicating copy to clipboard operation
serverless-plugins copied to clipboard

Offline SQS only seems to run jobs when first ran

Open Cyapow opened this issue 2 years ago • 1 comments

Hi guys

I'm working on SQS locally using the serverless-offline-sqs. All works swimmingly on the initial run and any jobs in the queue will run straight away or if no jobs are in the queue the first one I fire off will get processed

But if I add more jobs to the queue they don't get processed unless I restart the whole serverless command.

If anyone has experienced this before please let me know as that would be great.

Cyapow avatar Apr 19 '22 20:04 Cyapow

I was getting this too. My problem was that my handler was not async/returning a promise as I intended it to. The other option being calling the callback function. In other words your sqs lambda should be one of:

exports.handler =  function(event, context, callback) { ... callback(); ...}
exports.handler = async function(event) { .... }

psiservices-uwidmark avatar May 31 '22 16:05 psiservices-uwidmark