dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.2k stars 793 forks source link

Serverless offline exits call with "write EPIPE" #635

Closed BettyTheApp closed 5 years ago

BettyTheApp commented 5 years ago

I have the amazon linux 2 image locally running on a VirtualBox machine. I have SLS Version 1.14.0 I have NodeJS version 11.14.0

When i start 'sls offline' it runs until it wait for connection. When I connect to the server it starts handling the python file but ends with

[offline] HANDLER RESOLVED Serverless: Failure: events.js:170 throw er; // Unhandled 'error' event ^

Error: write EPIPE at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:67:16) Emitted 'error' event at: at errorOrDestroy (internal/streams/destroy.js:107:12) at onwriteError (_stream_writable.js:436:5) at onwrite (_stream_writable.js:461:5) at _destroy (internal/streams/destroy.js:49:7) at Socket._destroy (net.js:621:3) at Socket.destroy (internal/streams/destroy.js:37:8) at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:68:12)

I expected either the output from python or a usable error message.

My serverless.yml looks like this:

service: vendors # NOTE: update this with your service name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

package:
  exclude:
    - node_modules/**
    - venv/**

provider:
  name: aws
  runtime: python3.7
  environment:
    sAWSAccount: !Ref 'AWS::AccountId' #${file(../globalassets/account.yml):account}
    sVendorUserPool: xxxxxxxx
  apiGateway:
    restApiId: xxxxxxx # REST API resource ID. Default is generated by the framework
    restApiRootResourceId: xxxxxxx # Root resource, represent as / path
    description: Betty Platform main APIGateway # optional - description of deployment history
# you can overwrite defaults here
  stage: dev
  region: eu-west-1

plugins:
  - serverless-dynamodb-local
  - serverless-offline

functions:
  vendorProxy:
    handler: vendorProxy.vendorProxy
    role: LambdaVendorProxyRole
#    The following are a few example events you can configure
#    NOTE: Please make sure to change your handler code to work with those events
#    Check the event documentation for details
    events:
      - http:
          path: vendors/{proxy+}
          method: any
          authorizer: aws_iam

# you can add CloudFormation resource templates here

custom:
    serverless-offline:
      babelOptions:
        presets: ["es2015"]

resources:
  -  ${file(./resources/iam.yml)}
[log.txt](https://github.com/dherault/serverless-offline/files/3076341/log.txt)
BettyTheApp commented 5 years ago

Found the issue, it seemed that python3 was not correctly installed in the virtual environment.

When i typed python3 in the virtual environment i got errors because python wasn't able to load libraries. I reinstalled Pyhton3 via yum and all worked as it should.