ashiina/lambda-local

Not able to see response returned from express app converted to lambda using aws-serverless-express

tirthaguha opened this issue · 1 comments

I had a generic express application, created using express-generator.
I have converted it to a lambda using aws-serverless-express

the event that I'm sending is as follows

{
  resource: '/users',
  path: '/users',
  httpMethod: 'GET',
  requestContext: {
    resourcePath: '/users',
    httpMethod: 'GET',
    path: '/stage/',
  },
  headers: {
    accept:
      'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'accept-encoding': 'gzip, deflate, br',
    Host: 'XXXXXXXXXX.execute-api.us-east-2.amazonaws.com',
    'User-Agent':
      'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36',
    'X-Amzn-Trace-Id': 'Root=1-XXXXXXX-XXXXXXXXXXXXX',
  },
  multiValueHeaders: {
    accept: [
      'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    ],
    'accept-encoding': ['gzip, deflate, br'],
  },
  queryStringParameters: null,
  multiValueQueryStringParameters: null,
  pathParameters: null,
  stageVariables: null,
  body: null,
  isBase64Encoded: false,
}

This is my lambda-local script

lambdaLocal.execute({
  event: mock.payload,
  lambdaPath: path.join(__dirname, '../lambda.js'),
  profileName: 'default',
  timeoutMs: 3000,
  callback: function(err, data) {
    if (err) {
      console.log(err);
    } else {
      console.log(JSON.stringify(data));
      // console.log(data);
    }
  },
});

The output I get is

{
        "_events": {
                "listening": [
                        null,
                        null
                ]
        },
        "_eventsCount": 5,
        "_connections": 0,
        "_handle": {},
        "_usingWorkers": false,
        "_workers": [],
        "_unref": false,
        "allowHalfOpen": true,
        "pauseOnConnect": false,
        "httpAllowHalfOpen": false,
        "timeout": 120000,
        "keepAliveTimeout": 5000,
        "maxHeadersCount": null,
        "headersTimeout": 40000,
        "_socketPathSuffix": "ta2dc442bs",
        "_binaryTypes": [],
        "_pipeName": "\\\\?\\pipe\\C:\\Users\\User\\WORKSPACE\\test-app\\server-ta2dc442bs",
        "_connectionKey": "-1:\\\\?\\pipe\\C:\\Users\\User\\WORKSPACE\\test-app\\server-ta2dc442bs:-1"
}

Hi, this is likely not an lambda-local issue. Sorry for the answer delay (it's probably outdated now anyways).
Feel free to reopen with additional details if needed