Open Sharvin26 opened 3 years ago
You can use connection = getConnection();
to return the default connection and check if it already exists
I did this incase it threw and error and works fine in Lambda
let connection: Connection;
try {
connection = getConnection();
} catch (ex) { }
Package versions and database engine type:
Describe the bug Hello, thank you for creating this amazing driver. It's a lot helpful.
I am refering this issue for maintaing connection with Aurora Serverless and lambda.
I am using serverless framework as infrastucture as a code tool. The issue I am facing is when I make a first API call everything works properly but on second API call I get the following error:
To Reproduce The following is my
db.ts
where I have written all the logic for maintaing connection with reference to above issue.I am just calling this getData and addData methods from my lambda functions as follows:
function1:
function2:
Note: I am using serverless-offline plugin to run the code offline. ( Not sure if this may be causing the issue )
What I have seen is that cachedConnection becomes null on second different API call however it shouldn't.
Can you please check what I am doing wrong and how can I resolve this issue?