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

serverless-offline-sqs - SQS and HTTP events

Open manniniandrea opened this issue 4 years ago • 7 comments

Hello,

I'm trying to make this configuration work:

...
plugins:
  ...
  - serverless-offline-sqs #@4.0.1
  - serverless-offline #@6.4.0
custom:
  ...
  serverless-offline-sqs:
    autoCreate: true
    apiVersion: '2012-11-05'
    endpoint: http://localhost:9324
    region: eu-west-1
    accessKeyId: root
    secretAccessKey: root
    skipCacheInvalidation: false
provider:
  name: aws
  runtime: nodejs12.x
  region: eu-west-1
  ...
functions:
  main:
    handler: src/handlers/any.handler
    memorySize: 256
    events:
      - http:
          method: any
          path: /{any+}
          cors: true
  job:
    handler: src/handlers/job.handler
    memorySize: 256
    events:
      - sqs:
          arn:
            Fn::GetAtt:
              - MainQueue
              - Arn
resources:
  Resources:
    MainQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: "MainQueue"

Unfortunately, when i run the project, only one of the two lambda works.. what i mean is, if i run the project without the SQS plugins, the "http" lambda correctly starts up and i can make http calls at it, but when i start the project with the SQS plugin, only the SQS lambda correctly starts. Im unable to make them both work at the same time, any help?

manniniandrea avatar Jun 23 '20 19:06 manniniandrea

@manniniandrea I faced same issue, after a bit of debugging I was able to work it around by setting NODE_ENV=test

liquidautumn avatar Jul 01 '20 11:07 liquidautumn

I am also getting this bug.

I am curious, what causes this, and why does that environment variable help?

raymond-w-ko avatar Oct 23 '20 15:10 raymond-w-ko

Experienced the same problem here. I'm curious is this related to the ready method? What's the purpose of listening for termination?

fmquaglia avatar Dec 02 '20 15:12 fmquaglia

Experiencing the same issue... when serverless-offline-sqs is enabled.... good luck testing your lambda's directly! doesn't work. One or the other. Please fix this, defeats the entire purpose.

bitsofinfo avatar Dec 08 '20 03:12 bitsofinfo

@AdrieanKhisbe any ETA on a fix for this?

bitsofinfo avatar Dec 08 '20 03:12 bitsofinfo

@liquidautumn how did you figure out that setting that ENV got it to work?

bitsofinfo avatar Dec 08 '20 03:12 bitsofinfo

Even weirder, NODE_ENV=test is not needed if you add start to the command line. This does not work:

node ./node_modules/.bin/sls offline -s local --noPrependStageInUrl

This works:

node ./node_modules/.bin/sls offline start -s local --noPrependStageInUrl

The side effect is that you have to hit CTRL-C twice to exit.

raymond-w-ko avatar Dec 21 '20 16:12 raymond-w-ko