Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module initialization error: Error happens only on Lambda #11

Open
faizhasim opened this issue Mar 1, 2017 · 1 comment
Open

module initialization error: Error happens only on Lambda #11

faizhasim opened this issue Mar 1, 2017 · 1 comment

Comments

@faizhasim
Copy link

I am requiring a module provision-dynamodb in my serverless project (in which I'm one of the authors, so I can make changes to that module, if needed). Execution in lambda fails.

This is my lambda function:

const processConfigTables = require('provision-dynamodb');

export const hello = async (event: Object, context: Object, callback: Function) : any => {
  try {
    const result = await processConfigTables([{
      "name":"test-table",
      "readStrategy": {
        "name":"capacity-ratio",
        "upperThresholdRatio":0.8,
        "lowerThresholdRatio":0.15,
        "incrementRatio":3,
        "decrementRatio":0.8,
        "lowerBoundUnit":1,
        "upperBoundUnit":28},
      "writeStrategy": {
        "name":"capacity-ratio",
        "upperThresholdRatio":0.8,
        "lowerThresholdRatio":0.15,
        "incrementRatio":3,
        "decrementRatio":0.8,
        "lowerBoundUnit":1,
        "upperBoundUnit":28
      }
    }]);
    console.log('result = ', result);

    const response = {
      statusCode: 200,
      body: JSON.stringify({ok: true}),
    };

    return callback(null, response);
  } catch (err) {
    console.error('err', err);
    return callback(null, {
      statusCode: 500,
      body: JSON.stringify(err),
    });
  }
};

I got this error:

module initialization error: Error
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    at Object.<anonymous> (/var/task/handler.js:3177:4)
    at Object.96.../package.json (/var/task/handler.js:3197:4)
    at s (/var/task/handler.js:1:682)
    at /var/task/handler.js:1:733
    at Object.102.nconf (/var/task/handler.js:4220:142)
    at s (/var/task/handler.js:1:682)
    at /var/task/handler.js:1:733
    at Object.105../config (/var/task/handler.js:4229:519)
@faizhasim
Copy link
Author

faizhasim commented Mar 1, 2017

I rewrote the code in ES5, supported natively by node 4.3 and remove babelify transformation. I still run into the same problem.

If I totally remove browserfiy, it works fine.

const processConfigTables = require('provision-dynamodb');

module.exports.hello = (event, context, callback) => {
  processConfigTables([{
    "name":"test-table",
    "readStrategy": {
      "name":"capacity-ratio",
      "upperThresholdRatio":0.8,
      "lowerThresholdRatio":0.15,
      "incrementRatio":3,
      "decrementRatio":0.8,
      "lowerBoundUnit":1,
      "upperBoundUnit":28},
    "writeStrategy": {
      "name":"capacity-ratio",
      "upperThresholdRatio":0.8,
      "lowerThresholdRatio":0.15,
      "incrementRatio":3,
      "decrementRatio":0.8,
      "lowerBoundUnit":1,
      "upperBoundUnit":28
    }
  }]).then(result => {
    const response = {
      statusCode: 200,
      body: JSON.stringify({ok: true}),
    };

    return callback(null, response);
  }).catch(err => {
    return callback(null, {
      statusCode: 500,
      body: JSON.stringify(err),
    });
  });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant