Skip to content
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

"No X found" error thrown from a findUnique query does not show a stack trace #10641

Closed
capaj opened this issue Dec 10, 2021 · 0 comments · Fixed by #10645
Closed

"No X found" error thrown from a findUnique query does not show a stack trace #10641

capaj opened this issue Dec 10, 2021 · 0 comments · Fixed by #10645
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: error
Milestone

Comments

@capaj
Copy link

capaj commented Dec 10, 2021

Bug description

Error object thrown by prisma has no stack trace and message.
Stack trace and message should be available on all errors in node.js
when I call findUnique with rejectOnNotFound

How to reproduce

Have a code like this:

import { PrismaClient, Prisma } from '@prisma/client'

const prismaClient = new PrismaClient()


;(async () => {
    await prismaClient.user.findUnique({
        where: {
            id: 20 // make sure this does not exist in your DB
        },
        rejectOnNotFound: true
    })
})()

Running this code using ts-node pr.ts prints out:

[NotFoundError: No User found] { clientVersion: '3.6.0' }

Expected behavior

Stack trace in the error points into the line in user script where query was executed from.
For example an Error thrown should show up in stdout like this:

Error: this is how you throw an error
    at /home/capaj/work-repos/test/pr.ts:7:11
    at Object.<anonymous> (/home/capaj/work-repos/test/pr.ts:9:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/home/capaj/.nvm/versions/node/v16.13.0/lib/node_modules/ts-node/src/index.ts:1371:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/home/capaj/.nvm/versions/node/v16.13.0/lib/node_modules/ts-node/src/index.ts:1374:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at main (/home/capaj/.nvm/versions/node/v16.13.0/lib/node_modules/ts-node/src/bin.ts:331:12)

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./bugRepro.db"
}

model User {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  email     String   @unique
  name      String?

  role  String @default("USER")
  posts Post[]
}

Environment & setup

  • OS: ubuntu
  • Database: any
  • Node.js version: 17

Prisma Version

prisma                  : 3.6.0
@prisma/client          : 3.6.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio                  : 0.440.0

@capaj capaj added the kind/bug A reported bug. label Dec 10, 2021
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. topic: error labels Dec 13, 2021
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Dec 13, 2021
@Jolg42 Jolg42 added this to the 3.7.0 milestone Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants