You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I implement prisma logging, following their guide: Prisma Logging the logging works fine but when I use the Blitz wrapper enhancePrisma() Logs entries appear multiple times.
when initializing the client in the standard non-blitz way:
import { Prisma, PrismaClient } from "@prisma/client"
const customPrismaClient = new PrismaClient({
log: ['query']
})
Logs look this:
...
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ....
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"....
...
but when using the blitz wrapper...
import { Prisma, PrismaClient } from "@prisma/client"
const EnhancedPrisma = enhancePrisma(PrismaClient)
const customPrismaClient = new EnhancedPrisma({
log: ['query']
})
logs appear multiple times like so:
...
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ....
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ....
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ....
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"....
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"....
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"....
...
Sometimes the logs get repeated 2 sometimes even more
I can't say for sure but I have the feeling that the longer the server runs the more repetitions I see.
running Prisma 5.4.1
Paste all your error logs here:
example of repeated logs
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ("public"."user_account"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ("public"."user_account"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ("public"."user_account"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."user_account"."id" FROM "public"."user_account" WHERE ("public"."user_account"."id" = $1 AND 1=1) LIMIT $2 OFFSET $3
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"."permission_identifier" FROM "public"."user_permission" WHERE "public"."user_permission"."user_id" IN ($1) OFFSET $2
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"."permission_identifier" FROM "public"."user_permission" WHERE "public"."user_permission"."user_id" IN ($1) OFFSET $2
prisma:query SELECT "public"."user_permission"."user_id", "public"."user_permission"."permission_identifier" FROM "public"."user_permission" WHERE "public"."user_permission"."user_id" IN ($1) OFFSET $2
Paste all relevant code snippets here:
To reproduce:
import { Prisma, PrismaClient } from "@prisma/client"
const EnhancedPrisma = enhancePrisma(PrismaClient)
const customPrismaClient = new EnhancedPrisma({
log: ['query']
})
This one is really odd to me, logging used to work fine. It's possible Prisma made internal changes that render this enhancePrisma wrapper incompatible.
Here's the code for it, you can easily copy and paste it into your code to help debug at least.
Basically it does 3 things:
Ensure there is only a single client created
Wrap with a Proxy so that running new PrismaClient() in the browser doesn't throw an error. It's possible Prisma has changed to support that now
Add the $reset() method for testing convenience
A simpler approach for (1) without enhancePrisma is
if (!globalThis._prismaClient) {
globalThis._prismaClient = new PrismaClient()
}
export const prisma = globalThis._prismaClient
And you can solve (2) by doing your own check to not instantiate the client in the browser
What is the problem?
When I implement prisma logging, following their guide: Prisma Logging the logging works fine but when I use the Blitz wrapper enhancePrisma() Logs entries appear multiple times.
when initializing the client in the standard non-blitz way:
Logs look this:
but when using the blitz wrapper...
logs appear multiple times like so:
Sometimes the logs get repeated 2 sometimes even more
I can't say for sure but I have the feeling that the longer the server runs the more repetitions I see.
running Prisma 5.4.1
Paste all your error logs here:
example of repeated logs
Paste all relevant code snippets here:
To reproduce:
What are detailed steps to reproduce this?
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response
The text was updated successfully, but these errors were encountered: