Hi everyone, I'm getting an `Invalid `prisma.tagRa...
# orm-help
b
Hi everyone, I'm getting an `Invalid
prisma.tagRank.create()
invocation:`when running my app in a docker container but the error doesn't appear when running in local dev and build modes. Is there a way to get a more detailed log of which part of the .create() invocation is invalid? (ie. is it a syntax problem, arguments the wrong type etc) Thanks.
1
r
Hi Bryan 👋 To get additional logging output, set the
DEBUG
environment variable as described here
b
Hi Raphael. Thanks, will try it out now.
@Raphael Etim do you see any syntax or type errors with the following log? (
2022-09-16T19:13:49.125Z prisma:client Generated request: 2022-09-16T19:13:49.125Z prisma:client mutation { createOneTagRank(data: { name: "writing" count: 1 tagRankListId: "2082572d-df1d-4c6a-9e41-61ac68efbdb7" }) { id name count tagRankListId } }
The schema:
model TagRank {
id            String       @id @default(uuid())
name          String
count         Int
TagRankList   _TagRankList_ @relation(fields: [tagRankListId], references: [id])
tagRankListId String
@@index(tagRankListId)
}
I'm still getting the ``Invalid
prisma.tagRank.create()
invocation` even though the item is saved to the database
Some additional context the database operations finished successfully but immediately after I'm getting the following error:
Copy code
2022-09-16T19:13:59.596Z prisma:client:request_handler PrismaClientKnownRequestError: Timed out fetching a new connection from the connection pool. More info: <http://pris.ly/d/connection-pool> (Current connection pool timeout: 10, connection limit: 13) at prismaGraphQLToJSError (/app/node_modules/@prisma/client/runtime/index.js:20426:12) at LibraryEngine.buildQueryError (/app/node_modules/@prisma/client/runtime/index.js:26363:12) at LibraryEngine.request (/app/node_modules/@prisma/client/runtime/index.js:26297:22) at async RequestHandler.request (/app/node_modules/@prisma/client/runtime/index.js:29873:24) at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:30864:16) at async eval (webpack-internal:///(api)/./db-commands/rank-tags.ts:58:17) { code: 'P2024', clientVersion: '4.3.1', meta: { connection_limit: 13, timeout: 10 } }
Which is then followed by the invalid created() invocation. Sorry for the long logs!
r
From the logs, it shows that it timed out fetching a new connection from the connection pool. You can follow this guide to learn more on how you can manage the connection pool effectively.
b
Got it. Would a connection pool timeout also result in a .create() invocation error?
r
Can you share the query you are performing?
b
Sure, here is the query : `export const TagRankQuery = gql``
query {
fetchTagsRanked {
name
count
}
}
``` and the part that calls it:
const tagRankList = await prisma.tagRankList.create({
data: {
type,
start,
end,
},
})
const data: any = await RankTagQuery()
console.log('data', data.fetchTagsRanked)
data.fetchTagsRanked.forEach(async (tag: TagRank) => {
if (typeof tag.name !== 'undefined') {
await prisma.tagRank.create({
data: {
name: tag.name,
count: tag.count,
tagRankListId: tagRankList.id,
},
})
I am saving 300-600 items to a PostGres DB (Supabase) around the same time using the forEach loop so not sure if that might be overloading the connection pool
j
Could you change connection_limit=1?
b
Thanks for the suggestion, I read the docs and found that I was generating a new PrismaClient each time, the errors went away on the docker build when I switched to using only a single Prisma Client instance. I am now tackling the original issue I dockerized the project to solve: the api call stopping after the first line to fetch data is run on the deployed Vercel build (ie. logs show database operations started but no further action) I'm suspecting it might have to do with two ApolloClients being created (one to fetch data from external api and the other to fetch from Prisma connected PostGres DB)
r
Hi Bryan, glad to know the first issue was resolved. Have you had any luck with resolving the second issue?
b
Hi Raphael, I'm in contact with the Vercel support team to troubleshoot the second issue so will be waiting for their response. I've attached the repro below for reference but I think it might be an Apollo + Vercel issue rather than Prisma. https://github.com/maglev99/vercel-apollo-issue
r
Got it. I'll mark this as resolved then.
👍 2