AWS Lambda NodeJS bucket is idling out after 60 seconds

I have an interesting problem with AWS Lambda and NodeJS SDK 2.6.x. I have a Lambda function created with the serverless framework and it appears that the bucket is idling out after 60 seconds if I don’t somehow keep it alive.

I have the usual code inits outside of the Lambda body function:
cluster = new couchbase.Cluster(couchbase://x.x.x.x)
cluster.authenticate(username, password)
bucket = cluster.openBucket(bucketName)

If I make a query the first time using the Lambda and subsequent calls with less than 60 seconds then the bucket query will succeed just find… But if the Lambda is idle for more than 60 seconds, then the bucket query will fail and I will have wait about 2 seconds in the Lambda and try the query again (which will succeed the second time)

How do you keep the Lambda bucket alive. A Lambda container in AWS is typically up for about 15 minutes before it shuts down but the bucket is idling out in 60 seconds.

Has anyone run into this before?

May be one way could be to Ping instead of querying bucket ?

Are you proposing to call bucket.ping() every time and get a success before running the query?

For the record, I tried to ping and I always get a success but the query will fail if idle more than 60 seconds before last query. After the failure of the query you can try again and it will work.

There must be a TCP timeout from Lambda to Couchbase that seems to restore itself after a failed query. But it is costing an extra 2 seconds for a query in certain situations.