How to free used memory when using wrapper to catch async function in node js?

Viewed 21

I use wrapper for async function to catch errors.

wrap=fn=>{
    return (req,res,next)=>{
        fn(req,res,next).catch(next);
    }
}
let func=wrap(async(req,res,next)=>{
const conn=pool.connect()
......
conn.release()
} 

So, Here, How do I release the connection in case of error? Or Do I have to create try/catch/finally?

0 Answers
Related