Closed babpulss closed 3 months ago
and close pool in next.config.js process .once('SIGTERM', closePool) .once('SIGINT', closePool);
async function closePool() { try { await globalThis?.pool?.close() process.exit(0);
}
@babpulss Thank you for trying node-oracledb with Next.js. However, it is not clear on the exact requirement from node-oracledb with the connection pool as you have provided a solution.
What is the change that you require on the node-oracledb side?
Hi @babpulss , The management of pool ( or multiple pools) is done at the application layer and varies based on use-cases . Here is an example included for a typical web application.
From the node-oracledb driver , it provides various timeout parameters which can be used to control the connections/resources for a web application.
Closing this as not an issue with node-oracledb
I'm going to talk about the solution to the problem of creating a connection pool when using nextjs. The page that creates the connection pool was imported from each page, but due to the independent execution environment, the connection pool was created for each page, and this was not done with a consistent singleton, which led to unsatisfactory results. As a solution, I came up with a way to hold the created pool in a globalThis. ` declare global { var pool: Pool }
globalThis.pool = await createPool({ user: process.env.ORACLE_USER, password: process.env.ORACLE_PASSWORD, connectString: process.env.ORACLE_CONNECTSTRING, configDir: process.env.ORACLE_CONFIG_DIR, }); ` It turns out that this is a common pattern used by other nodejs libraries like prisma etc..
What is the link to the documentation section that needs improving?
Describe the confusion
Suggest changes that would help