Skip to content

PANIC in query-engine\core\src\query_graph_builder\read\utils.rs:52:85called Result::unwrap() on an Err value: FieldNotFound { name: "_count", model: "User" } #7217

Closed

Description

@41y08h

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v15.11.0
OS windows
Prisma Client 2.22.1
Query Engine query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c
Database postgresql
  app:error 
  app:error Invalid `prisma.video.findUnique()` invocation:
  app:error 
  app:error 
  app:error   PANIC in query-engine\core\src\query_graph_builder\read\utils.rs:52:85
  app:error called `Result::unwrap()` on an `Err` value: FieldNotFound { name: "_count", model: "User" }
  app:error 
  app:error This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.

Query

query {
  findUniqueVideo(where: {
    id: 5
  }) {
    id
    title
    description
    src
    thumbnail
    duration
    views
    uploadedAt
    channel {
      id
      name
      picture
      _count {
        subscribers
      }
    }
  }
}

Logs

  prisma:tryLoadEnv Environment variables loaded from C:\Users\Piyush\Documents\jstube\jstube-api\.env  
  prisma:tryLoadEnv Environment variables loaded from C:\Users\Piyush\Documents\jstube\jstube-api\.env  
  prisma:client clientVersion: 2.22.1  
  prisma:engine Search for Query Engine in C:\Users\Piyush\Documents\jstube\jstube-api\node_modules\.prisma\client  
  prisma:engine { cwd: 'C:\\Users\\Piyush\\Documents\\jstube\\jstube-api\\prisma' }  
  prisma:engine Search for Query Engine in C:\Users\Piyush\Documents\jstube\jstube-api\node_modules\.prisma\client  
  prisma:engine { flags: [ '--enable-raw-queries', '--port', '55058' ] }  
  prisma:engine stdout  Starting a postgresql pool with 9 connections.  
  prisma:engine stdout  Started http server on http://127.0.0.1:55058  
  prisma:engine Search for Query Engine in C:\Users\Piyush\Documents\jstube\jstube-api\node_modules\.prisma\client  
  prisma:engine Client Version: 2.22.1  
  prisma:engine Engine Version: query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c  
  prisma:engine Active provider: postgresql  
  prisma:engine stdout  PANIC in query-engine\core\src\query_graph_builder\read\utils.rs:52:85
called `Result::unwrap()` on an `Err` value: FieldNotFound { name: "_count", model: "User" }  
  prisma:engine {
  prisma:engine   error: Error: read ECONNRESET
  prisma:engine       at TCP.onStreamRead (node:internal/stream_base_commons:211:20) {
  prisma:engine     errno: -4077,
  prisma:engine     code: 'ECONNRESET',
  prisma:engine     syscall: 'read'
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: Error: connect ECONNREFUSED 127.0.0.1:55058
  prisma:engine       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1137:16) {
  prisma:engine     errno: -4078,
  prisma:engine     code: 'ECONNREFUSED',
  prisma:engine     syscall: 'connect',
  prisma:engine     address: '127.0.0.1',
  prisma:engine     port: 55058
  prisma:engine   }
  prisma:engine }  
  prisma:engine There is a child that still runs and we want to start again  
  prisma:engine { cwd: 'C:\\Users\\Piyush\\Documents\\jstube\\jstube-api\\prisma' }  
  prisma:engine Search for Query Engine in C:\Users\Piyush\Documents\jstube\jstube-api\node_modules\.prisma\client  
  prisma:engine { flags: [ '--enable-raw-queries', '--port', '55062' ] }  
  prisma:engine stdout  Starting a postgresql pool with 9 connections.  
  prisma:engine stdout  Started http server on http://127.0.0.1:55062  
  prisma:engine Search for Query Engine in C:\Users\Piyush\Documents\jstube\jstube-api\node_modules\.prisma\client  
  prisma:engine stdout  PANIC in query-engine\core\src\query_graph_builder\read\utils.rs:52:85
called `Result::unwrap()` on an `Err` value: FieldNotFound { name: "_count", model: "User" }  
  prisma:engine {
  prisma:engine   error: Error: read ECONNRESET
  prisma:engine       at TCP.onStreamRead (node:internal/stream_base_commons:211:20) {
  prisma:engine     errno: -4077,
  prisma:engine     code: 'ECONNRESET',
  prisma:engine     syscall: 'read'
  prisma:engine   }
  prisma:engine }  

Client Snippet

 const video = await prisma.video.findUnique({
    where: { id: videoId },
    select: {
      id: true,
      title: true,
      description: true,
      src: true,
      thumbnail: true,
      duration: true,
      views: true,
      uploadedAt: true,
      channel: {
        select: {
          id: true,
          name: true,
          picture: true,
          _count: {
            select: {
              subscribers: true,
            },
          },
        },
      },
    },
  });

Schema

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["selectRelationCount"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

enum Provider {
  GOOGLE
}

model User {
  id                Int             @id @default(autoincrement())
  name              String          @db.VarChar(255)
  email             String          @unique @db.VarChar(255)
  picture           String?
  provider          Provider
  providerAccountId String          @db.VarChar(100)
  comments          Comment[]
  videos            Video[]
  createdAt         DateTime        @default(now())
  commentRatings    CommentRating[]
  videoRatings      VideoRating[]
  subscribers       Subscriber[]    @relation("subscriber")
  subscriptions     Subscriber[]    @relation("channel")
}

model Video {
  id          Int           @id @default(autoincrement())
  title       String
  description String
  src         String
  thumbnail   String
  duration    Int
  userId      Int
  views       Int?          @default(0)
  channel     User?         @relation(fields: [userId], references: [id])
  comments    Comment[]
  uploadedAt  DateTime      @default(now())
  updatedAt   DateTime      @updatedAt
  ratings     VideoRating[]
}

model Comment {
  id               Int             @id @default(autoincrement())
  text             String          @db.VarChar(1000)
  baseCommentId    Int?
  baseComment      Comment?        @relation("baseComment", fields: [baseCommentId], references: [id])
  replies          Comment[]       @relation("baseComment")
  replyToCommentId Int?
  replyToComment   Comment?        @relation("replyToComment", fields: [replyToCommentId], references: [id])
  directReplies    Comment[]       @relation("replyToComment")
  userId           Int
  author           User            @relation(fields: [userId], references: [id])
  videoId          Int
  commentedOnVideo Video           @relation(fields: [videoId], references: [id])
  commentedAt      DateTime        @default(now())
  editedAt         DateTime        @updatedAt
  Rating           CommentRating[]
}

enum RatingStatus {
  LIKED
  DISLIKED
}

model VideoRating {
  id      Int          @id @default(autoincrement())
  status  RatingStatus
  userId  Int
  ratedBy User         @relation(fields: [userId], references: [id])
  videoId Int?
  video   Video?       @relation(fields: [videoId], references: [id])

  @@unique([videoId, userId])
}

model CommentRating {
  id        Int          @id @default(autoincrement())
  status    RatingStatus
  userId    Int
  ratedBy   User         @relation(fields: [userId], references: [id])
  commentId Int?
  comment   Comment?     @relation(fields: [commentId], references: [id])

  @@unique([commentId, userId])
}

model Subscriber {
  id        Int  @id @default(autoincrement())
  channelId Int
  channel   User @relation("channel", fields: [channelId], references: [id])
  userId    Int
  user      User @relation("subscriber", fields: [userId], references: [id])

  @@unique([channelId, userId])
}

Activity

  1. janpio commented on May 22, 2021

    @janpio
    Contributor

    This is a duplicate of #6543 Please follow that issue for a fix or information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedkind/bugtopic: basic error reporttopic: selectRelationCount

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions