How does node mysql2/promise’s connection pool release the connection?

  node.js, question

Because the connection pool using mysql2/promise did not release the connection, mysql will report the CAN’t CREATE MORE THANMAX _ PREPARED _ STMT _ COUNTSTATEMENTS error at last. How will it release the connection?
My code is like this
1. Create a connection

const mysql = require('mysql2/promise')
 var connection =  mysql.createPool(mysqlConfig)
 global.connection = connection

2. Mount the link to ctx

app.use(async (ctx, next) => {
 ctx.mysqlConection = global.connection
 // console.log(global.connection, '99999999999')
 ctx.controller = controller
 ctx.service = service
 ctx.are = are
 ctx.iz = iz
 ctx.rules = rules.rules
 ctx.model = mongodb.mongoose.models;
 await next()
 3. You can use the connection in the controller.
findUv: async function (ctx) {
 let condition = ctx.request.body
 let sql = `SELECT count AS uv FROM gugudai_count ORDER BY id ASC LIMIT 1`
 const [rows, fields] = await ctx.mysqlConection.execute(sql)
 // let conne=await ctx.mysqlConection.getConnection;
 // console.log(conne)
 return { rows }

After reading your reply and looking at the official website API, it is possible that your writing style is fine in other packages, but it does not conform to the requirements.mysql2The realization of. For example, the link was not created at the beginning, but was created on demand and recycled by itself.

// For pool initialization, see above
 pool.getConnection(function(conn) {
 // Do something with the connection
 conn.query(/* ... */);
 // Don't forget to release the connection when finished!