kevva / get-proxy

Get configured proxy
MIT License
15 stars 2 forks source link

Error w/ AWS Lambda Handler #4

Closed atwoodjw closed 8 years ago

atwoodjw commented 8 years ago

I'm trying to use download within an AWS Lambda Handler, written in Node.js, but I'm seeing an error.

{
  "errorMessage": "rc(name): name *must* be string",
  "errorType": "Error",
  ...
}

The following line seems to be the culprit.

const conf = require('rc')('npm');
kevva commented 8 years ago

That's weird. We clearly define a name (npm).

atwoodjw commented 8 years ago

Here's a Gist for the handler.

The code is simple, but I'm running through Browserify.

function handler(event, context, cb) {

  var conf = require('rc')('npm');

  return cb(null, {
    message: 'Your Lambda function executed successfully!'
  });
}

exports.handler = handler;
SamVerschueren commented 8 years ago

I might not be following here but why are you using browserify for AWS Lambda? Lambda isn't a browser, it's just a service that executes your node app within a docker container.

Just write your code, zip everything and upload to lambda.

atwoodjw commented 8 years ago

I'm using the Serverless framework with the Optimizer plugin. This isn't required, but reduces the file sizes of functions and purportedly decreases provisioning time.

I can setup an example function that doesn't use the Optimizer plugin if that's helpful.

SamVerschueren commented 8 years ago

Try it without the optimizer plugin first to make sure it's not a browserify issue.

atwoodjw commented 8 years ago

Browserify does not support !module.parent, which rc uses for a conditional log statement.

Please close.