title: Serverless: Lambda starts working only after a change from console/ Lambda intermittent behavior
body: <p>I am using serverless framework for lambda deployment and I am facing this really weird problem. I use Sequelize to connect to RDS Aurora MySql DB. The deployment is successful, but when I invoke the APIs I see <code>SequelizeConnectionError: Connect ETIMEDOUT</code>. The API works fine when I run offline. But the APIs deployed don't work. They start working as soon as I make any small change on the console and save it, like changing time out from 30 to 31. But when I redeploy I face the same problem and I just can't figure out what the problem is. </p>
  
  <p>Error:</p>
  
  <pre><code>SequelizeConnectionError: connect ETIMEDOUT
  </code></pre>
  
  <p>Edits:</p>
  
  <p>Yes. This is Aurora serverless with Data API enabled. The lambda function runs in the same VPC as the DB is in. The security group and subnets are are also same. Here is my DB config snippet:</p>
  
  <pre><code>DB_PORT: 3306 
  DB_POOL_MAX: 10 
  DB_POOL_MIN: 2 
  DB_POOL_ACQUIRE: 30000 
  DB_POOL_IDLE: 10000
  </code></pre>
  
  <p>This is my db.js:</p>
  
  <pre><code>const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, {
      host: process.env.DB_HOST,
      port: process.env.DB_PORT,
      dialect: 'mysql',
      pool: {
          max: process.env.DB_POOL_MAX, 
          min: process.env.DB_POOL_MIN,
          acquire: process.env.DB_POOL_ACQUIRE,
          idle: process.env.DB_POOL_IDLE
      }
  });
  </code></pre>
  
  <p>My handler file is really long with over 33 APIs. Below is one of them:</p>
  
  <pre><code>context.callbackWaitsForEmptyEventLoop = false;
    if (event.source === 'serverless-plugin-warmup') {
      try {
        const { Datalogger } = await connectToDatabase();
      } catch (err) { }
  
      return {
        statusCode: 200,
        headers: { 'Access-Control-Allow-Origin': '*' },
        body: 'warm-up'
      }
    }
  
    try {
      const { Datalogger } = await connectToDatabase();
      var datalogger;
      if (!event.headers.dsn &amp;&amp; !event.headers.sftp)
        throw new HTTPError(404, `Datalogger serial number and SFTP root directory is mandatory`);
  
      datalogger = await Datalogger.findOne({
        where: {
          dsn: event.headers.dsn,
          sftpRootDir: event.headers.sftp,
        }
      })
  
      if (!datalogger)
        throw new HTTPError(404, `Datalogger with this input was not found`);
  
  
      console.log('datalogger', datalogger);
  
      await datalogger.destroy();
  
      return {
        statusCode: 200,
        headers: { 'Access-Control-Allow-Origin': '*' },
        body: JSON.stringify(datalogger)
      }
    } catch (err) {
      console.log('Error in destroy: ', JSON.stringify(err));
  
      return {
        statusCode: err.statusCode || 500,
        headers: { 'Content-Type': 'text/plain', 'Access-Control-Allow-Origin': '*' },
        body: err.message || 'Could not destroy the datalogger.'
      }
    }
  </code></pre>
  
  <p>I reached out to AWS support for this issue and they suspect the error has occurred due to node js version upgrade. I was previously using 8 and it was working. After upgrading to 10 its resulting in intermittent timeouts. Few calls are successful and then one failure. Now even if I go back to version 8, its same issue.</p>