serverless / serverless

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.
https://serverless.com
MIT License
46.38k stars 5.69k forks source link

Go local test takes forever in "Excluding development dependencies" step. #8461

Open bwpedro opened 3 years ago

bwpedro commented 3 years ago

When run serverless invoke local --function ${functionName} --path ${path} in a go function (using docker #4746), serverless takes forever in the "Excluding development dependencies" step.

It seems like it needs to deploy all functions before executing the local test.

In my case I have 3 functions in serveless.yml, one "Excluding development dependencies" for each function.

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...

I was trying in a different project which I have more than 30 functions and it just took forever to test and I just had to gave up using go and use node.js instead.

If I deploy the function and test the remote function (just invoke, without local) it works but if I make a change I have to deploy the whole function to test.

serverless.yml:

app: sp
service: smart-parking
provider:
    name: aws
    runtime: nodejs12.x
    profile: smart-parking
    memorySize: 128
    versionFunctions: false
    iamRoleStatements:
        - Effect: Allow
          Action: dynamodb:Query
          Resource:
              - '*'
        - Effect: Allow
          Action: dynamodb:PutItem
          Resource:
              - '*'
package:
    individually: true
    include:
        - '!*'
        - '!*/**'

functions:
    - ${file(functions/serverless.yml)}

custom:
    stage: ${opt:stage, self:provider.stage}

resources:
    - Conditions:
          isProd: !Equals ['${self:custom.stage}', prod]

    - ${file(resources/dynamodb.yml)}

functions/serverless.yml

user:
    name: ${self:app}-user-${self:custom.stage}
    handler: functions/user/main.handler
    package:
        include:
            - functions/user/*
            - functions/user/*/**
    environment:
        APP: ${self:app}
        STAGE: ${self:custom.stage}

parking:
    name: ${self:app}-parking-${self:custom.stage}
    handler: functions/parking/main.handler
    package:
        include:
            - functions/parking/*
            - functions/parking/*/**
    environment:
        APP: ${self:app}
        STAGE: ${self:custom.stage}

myGoFunction:
    name: ${self:app}-myGoFunction-${self:custom.stage}
    handler: functions/myGoFunction/main.go
    runtime: go1.x
    package:
        include:
            - functions/myGoFunction/*
            - functions/myGoFunction/*/**

Installed version: 2.9.0

I know the go function only works locally with docker and I can see my function running if I just wait the excluding development dependencies, but it just takes too much time if the project is big enough.

medikoo commented 3 years ago

@bwpedro please respect all bug template remarks and answer all questions carefully.

Note that as bug template states you need to put all the plugins out of a picture, otherwise it's likely that plugins are cause of the issue and in such case issue belongs to their repository

medikoo commented 3 years ago

Othwerwise, for general support please check:

bwpedro commented 3 years ago

Thanks for the answer @medikoo.

All plugins are out of picture. I said that in the end of the issue description.