What exactly i am doing wrong.. Prepared Query

[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
[{
"error": {
"json": {
"message": "prepared statement \"preparedConfig\" already exists",
"code": -32603,
"data": {
"code": "INTERNAL_SERVER_ERROR",
"httpStatus": 500,
"path": "config.fetch",
"zodError": null
}
}
}
}]
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
export const preparedConfig = db.query.config
.findFirst({
with: { ads: true, banners: true },
orderBy: [asc(config.config.id)],
})
.prepare("preparedConfig");

// Calling using trpc

fetch: publicProcedure.query(async ({ ctx }) => {
return await preparedConfig.execute();
}),
12 Replies
Andrii Sherman
Can you share a runtime you are using? Also the connection driver you are using and do you have this name only for this prepared statement or some other as well?
Yamato
YamatoOP2y ago
do you have this name only for this prepared statement or some other as well?
This is my first prepared statement
No description
Andrii Sherman
Do you see this error on the first run or just on subsequent runs/requests?
Yamato
YamatoOP2y ago
I think first time when i open the webpage it returned data but after that it's returning same error even tho i am hard reloading page now it's returning 500 error
Yamato
YamatoOP2y ago
No description
Andrii Sherman
and you are running it on vercel?
Yamato
YamatoOP2y ago
yes let me try locally same
Andrii Sherman
сс @bloberenober @alexblokh
Yamato
YamatoOP2y ago
Okay i tried other driver
No description
Yamato
YamatoOP2y ago
it's working now but performance is very poor
Yamato
YamatoOP2y ago
No description
Yamato
YamatoOP2y ago
PS: without prepare on @vercel/postgres locally i was getting 230ms

Did you find this page helpful?