Request from Lamdba locally never completes

I have some Serverless Lambdas written in Typescript and deployed to AWS with API Gateway. They work perfectly through the AWS Console and using serverless invoke local (on most machines).

Back when I was in the office before lockdown, they worked perfectly on my machine using serverless invoke local; and my integration tests which call the RDS database using the Lambdas, all passed when ran on this machine. Now, for some very strange reason that I can’t fathom, serverless invoke local now doesn’t return anything on this machine; and the tests all fail for the same reason. And it only happens on this machine! If any of my colleagues clone the same repository and run it on their machines, everything works and the tests pass. It even works perfectly on my old laptop (which is very slow and out of date and I can’t use it for work) connected to the same network!

I don’t believe it’s a problem with blocked ports or network settings on my machine, because other services that make external calls from local all work perfectly. To test this (and test my AWS settings) I’ve even set up a Java/Springboot project and made calls to exactly the same database on the same port. It calls the database and returns the data as expected.

Yet in the serverless project, when running serverless invoke local, it tells me the handlers have been built successfully and gives no errors (even with SLS_DEBUG=*, but doesn’t actually return the data.

Please see screenshots below. The top image is what should happen (and this is on my other machine running on the same network); and the bottom image is what happens on this machine:

And every test fails with:

: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

I’ve also tried using the serverless-offline plugin and when using that, the lambdas get built with no errors and when trying the endpoints in a browser or with postman, it does nothing. Just shows a never ending spinning wheel and ‘waiting for localHost’, even though this also works as expected on every other computer!

I’m running macOS Catalina 10.15.4 (did a fresh install thinking it might solve this error - but it had no effect!)

Here is my serverless.yml:

service:
  name: openspace-backend

custom:
  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true
  serverless-offline:
    httpPort: 4000


plugins:
  - serverless-webpack
  - serverless-dotenv-plugin

provider:
  name: aws
  runtime: nodejs12.x
  apiGateway:
    minimumCompressionSize: 1024 
  environment:
    AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
    PROD_DB_URI: ${env:PROD_DB_URI}
    PROD_DB_USER: ${env:PROD_DB_USER}
    PROD_DB_PASSWD: ${env:PROD_DB_PASSWD}
    PROD_DB_NAME: ${env:PROD_DB_NAME}
    DB_PORT: ${env:DB_PORT}

functions:
  getSessions:
    handler: SessionsHandler.getSessions
    events:
      - http:
          method: get
          path: /api/sessions

  addSession:
    handler: SessionsHandler.addASession
    events:
      - http:
          method: post
          path: /api/sessions

  editSession:
    handler: SessionsHandler.editASession
    events:
      - http:
          method: put
          path: /api/sessions/{id}

  deleteSession:
    handler: SessionsHandler.deleteASession
    events:
      - http:
          method: delete
          path: /api/sessions/{id}

  updateLike:
    handler: SessionsHandler.updateALike
    events:
      - http:
          method: post
          path: /api/sessions/{id}/likes/{email}

  getSpaces:
    handler: SpacesHandler.getSpaces
    events:
      - http:
          method: get
          path: /api/spaces

  addSpace:
    handler: SpacesHandler.addASpace
    events:
      - http:
          method: post
          path: /api/spaces

  editSpace:
    handler: SpacesHandler.editASpace
    events:
      - http:
          method: put
          path: /api/spaces/{id}

  deleteSpace:
    handler: SpacesHandler.deleteASpace
    events:
      - http:
          method: delete
          path: /api/spaces/{id}

And here is my package.json:

{
  "name": "openspace-backend",
  "version": "1.0.0",
  "description": "Serverless webpack example using Typescript",
  "main": "handler.js",
  "scripts": {
    "test": "jest"
  },
  "dependencies": {
    "@babel/core": "^7.9.6",
    "@babel/preset-env": "^7.9.0",
    "@babel/preset-typescript": "^7.9.0",
    "@types/pg": "^7.14.3",
    "aws-sdk": "^2.675.0",
    "babel-jest": "^25.5.1",
    "dotenv": "^8.2.0",
    "eslint": "^6.8.0",
    "pg": "^7.18.2",
    "serverless": "^1.70.1",
    "source-map-support": "^0.5.19",
    "to": "^0.2.9",
    "ts-postgres": "^1.1.3",
    "update": "^0.7.4"
  },
  "devDependencies": {
    "@types/aws-lambda": "^8.10.51",
    "@types/jest": "^25.2.1",
    "@types/node": "^10.17.21",
    "fork-ts-checker-webpack-plugin": "^3.0.1",
    "jest": "^25.5.4",
    "nyc": "^15.0.1",
    "serverless-dotenv-plugin": "^2.4.2",
    "serverless-webpack": "^5.3.2",
    "ts-jest": "^25.5.1",
    "ts-loader": "^5.3.3",
    "ts-mockito": "^2.5.0",
    "ts-node": "^8.10.1",
    "typescript": "^3.9.2",
    "webpack": "^4.43.0",
    "webpack-node-externals": "^1.7.2"
  },
  "author": "The serverless webpack authors (https://github.com/elastic-coders/serverless-webpack)",
  "license": "MIT"
}

I really would like to use the serverless framework but I can’t use it if it will not allow me to work in a local environment on this machine!

Please help!

Anyone had this issue before?