title: AWS Lambda invoke function (js sdk): timeout resets to default
body: <p>I am running a Meteor (Node 4.4.7) application that performs long operations on AWS Lambda. I invoke the lambda function from my code and wait for the response before proceeding to the next invocation. I set the timeout to 300000ms as described in a <a href="https://stackoverflow.com/questions/36648377/aws-lambda-invoke-function-doesnt-always-return">former question</a> (both on Lambda and in the AWS.Lambda object in my code).</p>
  
  <p>My problem is that sometimes the <code>AWS.Lambda</code> timeout value is reset to the default value of 120000ms. As my Lambda function takes more time to execute (but still less than the max 300s), I don't receive the response. Furthermore I see that my function is invoked 3 more times as per the default <code>maxRetries</code> value, even thought I set it to 1. </p>
  
  <p>I don't know the steps to reproduce it. It seems random. It usually happens after a couple of days running my app. If I check the properties of my <code>AWS.Lambda</code> object, it still has the 300000ms timeout value although it behaves like it has the default 120000ms value. Once this happens, all subsequent invocations requests have the same problem and I have to restart the app to make it work again.</p>
  
  <p>Note that on the Lambda logs, I see that the functions is being executed properly. Duration &lt; 120s returns in my code. Duration > 120s are retried.</p>
  
  <p><strong>Sample code:</strong> </p>
  
  <pre><code>var options = {
    maxRetries: 1,
    httpOptions: {
      timeout: 300000
    }
  };
  
  var lambda = new AWS.Lambda(options);
  
  var myEventObject = {...};
  var payload = JSON.stringify('myEventObject');
  
  var params = {
    FunctionName: 'myLambdaFunction'
    InvocationType: 'RequestResponse',
    LogType: 'None',
    Payload: payload
  };
  
  lambda.invoke(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
  });
  </code></pre>
  
  <p>Among the things I've tried: create a <code>new AWS.Lambda()</code> for each invocation.</p>