-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
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 sqlStmt
and 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;
desoss and ofirmalka
Metadata
Metadata
Assignees
Labels
No labels