Hi. There's an issue I can't resolve: I've got a route /product/[slug] and I want to generate pages at build time. But nextjs creates new instance of local api and therefore a new database connection for each dynamic param inside generateStaticParams(), and postgres throws an error of too many connections.
Here's some of the code:
`export const dynamic = 'force-static'
export const dynamicParams = true
export default async function ProductPage({ params }: params) {
if (!params.slug) {
return notFound()
}
const payload = await getPayloadClient()
const getProductData = (slug ) => unstable_cache(
async (slug) => {
//will create new local instance everytime and bypass getClient cache, why?
// const payload = await getPayloadClient()
return await payload.find({
collection: 'products',
where: {
slug: {
equals: slug,
},
},
})},
['product_data'],
{
tags: [`products_${slug}`],
},
)(slug )`
const productData = await getProductData(params.slug)
