title: Lambda function not inserting into Postgres RDS
body: <p>I am trying to insert a record into RDS Postgres using node.js lambda function.  I can't tell if it is connecting to the database or not.  It did insert 3 records once and then nothing.  Nothing is being written to the log.  Below is my code:</p>
  <pre><code>'use strict';
  
   const { Client } = require('pg') ; 
   const client = new Client();
   client.connect();
    
  
  exports.handler = async function(event, context) {
    
   var response;
    
    if (event.Records) {    
      for (let record of event.Records) {
      
          var rec = JSON.parse(JSON.stringify(record.body));
          var test = JSON.parse(rec);
  
          console.log(&quot;test id:&quot; + test.id);
          
          const queryString = {
              text: &quot;INSERT INTO public.order VALUES ($1, $2, $3, $4)&quot;,
              values: [test.id, test.email, test.total_price, test.token],
          };
    
          try{
              const result = await client.query(queryString);       
              console.log(result.rowCount);        
              response = result.rowCount;
          }
          catch (err) {
              console.log(err.stack);
          } 
  }
      client.end();
  }
    return response;
  };
  
  </code></pre>
  <p>The log output is:</p>
  <p>INFO    test id:820982911946154500</p>
  <p>INFO    Error: Client was closed and is not queryable    at /opt/nodejs/node_modules/pg/lib/client.js:570:27    at processTicksAndRejections (internal/process/task_queues.js:79:11)</p>
  <p>Any help is appreciated.  Thanks.</p>