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

Lambda function dies at query with no error #116

Open
fifty-git opened this issue Aug 31, 2021 · 3 comments
Open

Lambda function dies at query with no error #116

fifty-git opened this issue Aug 31, 2021 · 3 comments

Comments

@fifty-git
Copy link

fifty-git commented Aug 31, 2021

I've got a lambda app with two functions that connect to the same Aurora RDS. Lambda 1 connects fine and does an UPDATE.

Lambda 2 tries to do a SELECT and dies right at the mysql.query(). The strange thing is, the app runs fine locally with serverless-offline and Lambda 1 works fine locally and on AWS.

Normally because it dies without an error, I would think that it would be a network security issue, but lambda 1 connects fine.

I've logged out the sqlStmtand it's all there.

UPDATE: another developer working with this package just reported the same issue to me. The only thing we can figure is it's the connection.

Here's the code that appears to fail:

    const results = await mysql
      .query({
        sql: sqlStmt,
        timeout: 100000,
        values: [
          startDate,
          endDate,
          startDate,
          endDate,
          startDate,
          endDate,
          startDate,
          endDate,
        ],
      })
      .catch((error) => {
        console.log('DB ERROR', error);
      });
console.log('RESULTS', results);  // this never runs

Here is the connection set up:

const AWS = require('aws-sdk');

const env = process.env.NODE_ENV || 'development';
// const env = 'production';
const dbConf = require('../config/config.json')[env];

AWS.config.logger = console;
// eslint-disable-next-line import/order
const mysql = require('serverless-mysql')({
  backoff: 'decorrelated',
  base: 5,
  cap: 200,
  port: 3306,
  config: {
    host: dbConf.host,
    database: dbConf.database,
    user: dbConf.user,
    password: dbConf.password,
    multipleStatements: true,
  },
  onError: (e) => {
    console.log('DB ERROR ', e.code);
  },
  onConnectError: (e) => {
    console.log('Connect Error', e.code);
  },
});

module.exports = mysql;
@Martin86Ec
Copy link

Same problem here, worked for some hours. Then the instance was never able to hit the db.

@EArminjon
Copy link

same

1 similar comment
@ofirmalka
Copy link

same

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

4 participants