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
findFirstOrThrow / findUniqueOrThrow errors are not reported via error
event
#14933
Comments
error
event
Reopening until client changes to use the server endpoints have landed xref: #16162 |
Superseded by #16226 |
Hello! Sorry for writing on a closed issue but, after updating For instance, for this code:
it is throwing me some errors on the console like so:
A way to get around that is to ditch the
Though, this approach is undesirable because I'm not using a prisma functionality that is quite useful. Am I doing something wrong? Can anybody help me? Thank you in advance, and I apologize if I lack the knowledge to proper do something, my basis is from Electric Engineering and not IT. |
Hello @SpecialAro!
In this case you are not only checking the existence of a For that, I think the appropriate API is the one you suggest, to use Having said that, the error logged in the console informs about a field not present in the model, which should be a bug. Would you mind filing a new bug report, please? and include information for reproduction, including a schema file, so we can help you better? Thank you. |
@SpecialAro no need to report anymore. Your report was also captured by #16549. A fix is on the way. prisma/prisma-engines#3458 |
Thank you so much @miguelff ! Got caught up with work and didn't had time to open an issue sooner, sorry. Nevertheless, I'm really glad that a fix is already on the way 😁 I'll hold back the update until further notice, then. Thank you again, loving prisma so far ❤️ |
Bug description
When
findFirstOrThrow
orfindUniqueOrThrow
can't find a model instance, an error is thrown. This error is not currently catchable as it doesn't trigger a Prismaerror
event, nor is it thrown bynext
inside of middlewares.This is the issue which was described by @bbenezech in this comment and confirmed to be a bug by @janpio .
For us the immediate effect is that the error is not logged by our custom logger, which results in 5 or 6 error lines in Datadog (triggering error alerting).
How to reproduce
prisma.$on("error", ...)
event hookprisma.$use(...)
middlewarefindFirstOrThrow
query that is guaranteed to failExpected behavior
I would expect one of those two behaviours (or both) :
error
event hook is callednext
in the middleware so i can catch it and treat it accordinglyPrisma information
This happens for all models but should be reproducible with this minimal schema :
Client queries :
☝️ The above code returns the following in console :
Environment & setup
The code runs on this Docker image : node:16-alpine
Prisma Version
The text was updated successfully, but these errors were encountered: