Repository navigation
Closed
Labels
bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.topic: basic error reporttopic: selectRelationCount
Milestone
Description
Hi Prisma Team! My Prisma Client just crashed. This is the report:
Versions
| Name | Version |
|---|---|
| Node | v14.16.1 |
| OS | windows |
| Prisma Client | 2.22.1 |
| Query Engine | query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c |
| Database | undefined |
Query
query {
findUniqueUser(where: {
username: "X"
}) {
id
username
email
password
avatar
header_img
created_at
bio
deleted
card_number
goal
payment_frequency
full_name
profession
verified
social_media
type
posts(
where: {
deleted: false
}
orderBy: [
{
created_at: desc
}
]
take: 5
) {
title
text
_count {
likes
comments
}
}
}
}
Logs
prisma:tryLoadEnv Environment variables loaded from D:\Projects\patreon-back\.env
prisma:tryLoadEnv Environment variables loaded from D:\Projects\patreon-back\.env
prisma:client clientVersion: 2.22.1
prisma:engine { cwd: 'D:\\Projects\\patreon-back\\prisma' }
prisma:engine Search for Query Engine in D:\Projects\patreon-back\node_modules\.prisma\client
prisma:engine Search for Query Engine in D:\Projects\patreon-back\node_modules\.prisma\client
prisma:engine { flags: [ '--enable-raw-queries', '--port', '56935' ] }
prisma:engine stdout Starting a mysql pool with 9 connections.
prisma:engine stdout Started http server on http://127.0.0.1:56935
prisma:engine Search for Query Engine in D:\Projects\patreon-back\node_modules\.prisma\client
prisma:engine Stopping Prisma engine4
prisma:engine Waiting for start promise
prisma:engine Done waiting for start promise
prisma:engine Client Version: 2.22.1
prisma:engine Engine Version: query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c
prisma:engine Active provider: mysql
prisma:engine { cwd: 'D:\\Projects\\patreon-back\\prisma' } +6s
prisma:engine Search for Query Engine in D:\Projects\patreon-back\node_modules\.prisma\client
prisma:engine { flags: [ '--enable-raw-queries', '--port', '56954' ] }
prisma:engine stdout Starting a mysql pool with 9 connections.
prisma:engine stdout Started http server on http://127.0.0.1:56954
prisma:engine Search for Query Engine in D:\Projects\patreon-back\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: "Post" }
prisma:engine {
prisma:engine error: Error: read ECONNRESET
prisma:engine at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
prisma:engine errno: -4077,
prisma:engine code: 'ECONNRESET',
prisma:engine syscall: 'read'
prisma:engine }
prisma:engine }
prisma:engine {
prisma:engine error: Error: write ECONNRESET
prisma:engine at afterWriteDispatched (internal/stream_base_commons.js:156:25)
prisma:engine at writevGeneric (internal/stream_base_commons.js:139:3)
prisma:engine at Socket._writeGeneric (net.js:783:11)
prisma:engine at Socket._writev (net.js:792:8)
prisma:engine at doWrite (internal/streams/writable.js:375:12)
prisma:engine at clearBuffer (internal/streams/writable.js:521:5)
prisma:engine at Socket.Writable.uncork (internal/streams/writable.js:317:7)
prisma:engine at write (D:\Projects\patreon-back\node_modules\@prisma\client\runtime\index.js:25825:14)
prisma:engine at _resume (D:\Projects\patreon-back\node_modules\@prisma\client\runtime\index.js:25731:31)
prisma:engine at resume (D:\Projects\patreon-back\node_modules\@prisma\client\runtime\index.js:25630:5) {
prisma:engine errno: -4077,
prisma:engine code: 'ECONNRESET',
prisma:engine syscall: 'write'
prisma:engine }
prisma:engine }
prisma:engine {
prisma:engine error: Error: connect ECONNREFUSED 127.0.0.1:56954
prisma:engine at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
prisma:engine errno: -4078,
prisma:engine code: 'ECONNREFUSED',
prisma:engine syscall: 'connect',
prisma:engine address: '127.0.0.1',
prisma:engine port: 56954
prisma:engine }
prisma:engine }
Client Snippet
const result = await db.user.findUnique({
where: {
username,
},
select: {
posts: {
where: {
deleted: false,
},
orderBy: {
created_at: "desc",
},
take: 5,
select: {
_count: {
select: {
comments: true,
likes: true,
},
},
},
},
},
});Schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["selectRelationCount"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
id Int @id @default(autoincrement())
title String @db.VarChar(250)
text String? @db.Text
poll Poll[] @relation(name: "pollPost")
created_at DateTime @default(now()) @db.DateTime(6)
userId Int
author User @relation(name: "posts", fields: [userId], references: [id])
comments Comments[]
likes Likes[] @relation(name: "postLikes")
protected Boolean @default(true)
images Json?
audio String?
deleted Boolean @default(false)
@@index([userId, created_at])
@@map("posts")
}
model Comments {
id Int @id @default(autoincrement())
created_at DateTime @default(now()) @db.DateTime(6)
likes Int
replies Int
userId Int
postId Int
post Post @relation(fields: [postId], references: [id])
author User @relation(fields: [userId], references: [id])
@@map("comments")
}
model Likes {
id Int @id @default(autoincrement())
userId Int
postId Int
User User @relation("userLikes", fields: [userId], references: [id])
Post Post @relation("postLikes", fields: [postId], references: [id])
@@unique([userId, postId])
@@map("likes")
}
The issue gets fixed when i remove _count
Metadata
Metadata
Assignees
Labels
bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.topic: basic error reporttopic: selectRelationCount
Activity
pantharshit00 commentedon May 20, 2021
Hey @mostafa7904
Can you please share the
Usermodel here as well?mostafa7904 commentedon May 20, 2021
Sure.
janpio commentedon May 22, 2021
This is a duplicate of #6543 Please follow that issue for a fix or information.