New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug(qe): errors don't get logged #16226
Comments
We just upgraded prisma and found that the client logger was logging query errors. We found this a bit baffling as this should be handled by the service where the queries run from, and they should be logged or not depending on the business requirements. I would have expected that the client errors listener would log connection errors, internal errors from prisma, and other parts related to the query engine/pools and internals. Not query errors. |
What would the "service where the queries run from" be in your interpretation? In my understanding there is only one component for Prisma Client users, which is Prisma Client - where you can configure the logging in certain ways. |
@janpio we use insert as means to create idempontent requests, knowing that duplicate inserts will result in an error: since the upgrade we see these What i mean by this, is that service implementation caused the error, not the prisma client in some unrelated way from the application. Hope my reply makes more sense. |
Yeah I think I follow. What logging do you have enabled in Prisma Client? |
Probably easier to show it: Query/Info are disabled in prod. I am not sure why the community wants this feature. But for us we would like to be able to exclude these errors.
|
And via which of those are errors now unexpectedly logged? |
The error callback. (You can see the filtering done in the if statement)
|
Ok, if you do not want the error caused by queries to be logged there, which would you then want to have logged? I am still trying to build a complete picture here. |
I will refer to my original comment:
We didnt had this behavior in prisma in older versions. what caused the change to encompass this? |
See from above:
|
I am facing this same problem as @ricardolpd. I updated my Prisma version from 3.15 to the latest and was baffled by the large amount of log output from tests that expect an exception. I tried to suppress it by passing It looks very strange that the error log is output even when an exception is caught. Is there any way to prevent the error log from being output? |
Supersedes #14933
Background
Prisma can be configured to log events to stdout or emit logging events. Those events can be categorized into four levels which do not have a hierarchical relationship with each other. (A logging level does not include events from any other level)
One of these levels is
error
, but the reference doesn't specify what is eligible to be logged using this level.Given that the reference has a section on errors users might have the reasonable expectation that, when any of those happen, an event is logged to the console or emitted for subscription depending on the configuration.
This is manifested in past issues like #14933, but given the reproduction scenarios below, the problem is not restricted to
findFirstOrThrow
andfindUniqueOrThrow
NotFound
errors, but to all the errors happening in PrismaReproduction
I created two reproduction scenarios, using the libray engine and the binary engine (As they exercise two different code paths for dispatching requests coming from the prisma client)
Both resulted on the error not being logged.
Premise: the engine was tricked to through a panic when dispatching a query
Scenario 1 - Binary engine
index.ts
prisma.schema
Result:
Scenario 2 - Library engine
index.ts
prisma.schema
Result
Expected behavior
The specifics have to be determined. There's no previous record in the codebase to determine the correct behavior. And the reference of what constitutes an error is vague enough as to require a specification of how this should behave.
My proposal is to log with the error level what is said to constitute an error in the error reference thus following the principle of least astonishment. But I'd like to count with @janpio's take on how this should behave before jumping into implementation.
Definition of done
The text was updated successfully, but these errors were encountered: