Repository navigation
Closed
prisma/prisma-engines
#1980Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: previewFeaturesIssue touches on an preview feature flagtopic: selectRelationCount
Milestone
Description
I got an error when I tried to use your new selectRelationCount feature.
Versions
| Name | Version |
|---|---|
| Node | v14.16.0 |
| OS | darwin |
| Prisma Client | 2.20.1 |
| Query Engine | query-engine 60ba6551f29b17d7d6ce479e5733c70d9c00860e |
| Database | undefined Edit by @janpio: prisma:engine Active provider: postgresql |
Query
query {
findUniqueSpace(where: {
id: 5
}) {
id
createdAt
updatedAt
name
about
_count {
stories
lists
}
stories(where: {
isPublic: true
}) {
id
userId
createdAt
updatedAt
text
spaceId
listId
isPublic
user {
id
name
nick
handle
photoUrl
}
senses {
id
knownAs {
valId
senseId
type
createdAt
pickCount
skipCount
val {
id
n
adj
}
}
teaser
text
}
}
lists(where: {
unlisted: false
}) {
name
uuid
randosCanJoin
isPracticeGroup
_count {
memberships
stories
}
}
}
}
Logs
ent/runtime/index.js:24152:10)
at LineStream.Transform._read (internal/streams/transform.js:205:10)
at LineStream.Transform._write (internal/streams/transform.js:193:12)
at writeOrBuffer (internal/streams/writable.js:358:12)
at LineStream.Writable.write (internal/streams/writable.js:303:10)
at Socket.ondata (internal/streams/readable.js:719:22)
at Socket.emit (events.js:315:20) {"timestamp":"Apr 13 10:16:44.809","level":"ERROR","fields":{"message":"PANIC","reason":"called `Result::unwrap()` on an `Err` value: FieldNotFound { name: \"_count\", model: \"List\" }","file":"query-engine/core/src/query_graph_builder/read/utils.rs","line":52,"column":85},"target":"query_engine","span":{"name":"find_related"},"spans":[{"name":"execute_single_operation"},{"name":"build"},{"name":"build_internal"},{"name":"dispatch_build"},{"name":"find_unique"},{"name":"find_related"}]}
prisma:engine Client Version: 2.20.1
prisma:engine Engine Version: query-engine 60ba6551f29b17d7d6ce479e5733c70d9c00860e
prisma:engine Active provider: postgresql
prisma:engine {
error: SocketError: other side closed
at Socket.onSocketEnd (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:25293:24)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'UND_ERR_SOCKET'
}
}
prisma:engine { cwd: '/Users/joeedelman/Dropbox/repos/warez/mvill/db' }
prisma:engine Search for Query Engine in /Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/.prisma/client
plusX Execution permissions of /Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/.prisma/client/query-engine-darwin are fine
prisma:engine {
flags: [
'--enable-experimental=selectRelationCount',
'--enable-raw-queries',
'--port',
'52506'
]
}
prisma:engine stdout Starting a postgresql pool with 5 connections.
prisma:engine stdout Started http server on http://127.0.0.1:52506
prisma:engine Search for Query Engine in /Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/.prisma/client
plusX Execution permissions of /Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/.prisma/client/query-engine-darwin are fine
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: "List" }
prisma:engine TypeError: this.currentRequestPromise.cancel is not a function
at NodeEngine.handlePanic (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:27023:36)
at NodeEngine.setError (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:26969:16)
at LineStream.<anonymous> (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:27259:24)
at LineStream.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at LineStream.Readable.push (internal/streams/readable.js:223:10)
at LineStream.Transform.push (internal/streams/transform.js:166:32)
at LineStream._pushBuffer (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:24158:19)
at LineStream._transform (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:24152:10)
at LineStream.Transform._read (internal/streams/transform.js:205:10)
at LineStream.Transform._write (internal/streams/transform.js:193:12)
at writeOrBuffer (internal/streams/writable.js:358:12)
at LineStream.Writable.write (internal/streams/writable.js:303:10)
at Socket.ondata (internal/streams/readable.js:719:22)
at Socket.emit (events.js:315:20) {"timestamp":"Apr 13 10:16:44.955","level":"ERROR","fields":{"message":"PANIC","reason":"called `Result::unwrap()` on an `Err` value: FieldNotFound { name: \"_count\", model: \"List\" }","file":"query-engine/core/src/query_graph_builder/read/utils.rs","line":52,"column":85},"target":"query_engine","span":{"name":"find_related"},"spans":[{"name":"execute_single_operation"},{"name":"build"},{"name":"build_internal"},{"name":"dispatch_build"},{"name":"find_unique"},{"name":"find_related"}]}
prisma:engine {
error: SocketError: other side closed
at Socket.onSocketEnd (/Users/joeedelman/Dropbox/repos/warez/mvill/node_modules/@prisma/client/runtime/index.js:25293:24)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'UND_ERR_SOCKET'
}
}
Client Snippet
await db.space.findUnique({
where,
include: {
_count: {
select: {
stories: true,
lists: true,
},
},
stories: {
where: {
isPublic: true,
},
include: {
user: SelectUser,
senses: SelectSense,
},
},
lists: {
select: {
name: true,
uuid: true,
randosCanJoin: true,
isPracticeGroup: true,
_count: {
select: {
memberships: true,
stories: true,
},
},
},
where: {
unlisted: false,
},
},
},
})Schema
// PLEASE ADD YOUR SCHEMA HERE IF POSSIBLEReacted by Alex and Samuel Schlesinger
Metadata
Metadata
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: previewFeaturesIssue touches on an preview feature flagtopic: selectRelationCount
Activity
matthewmueller commentedon Apr 14, 2021
Do you mind adding your prisma schema or a minimal repro? Thanks!
subnomo commentedon May 5, 2021
I have also been getting this error. It seems to happen when you try to use
_counton nestedincludeorselects.According to the docs,
_countcan only be used in a top-levelincludeorselect. However TypeScript doesn't complain when I try to use it in a nested way, Prisma just panics.At the very least I think the error message should be better, but I definitely have a use case for nested
_count, and I wish it would work as expected.janpio commentedon May 22, 2021
Multiple more reports with reproduction schemas and with newer versions, reproductions confirmed by @pantharshit00 in the follow duplicate issues: #7091 + #7151 + #7217
41y08h commentedon May 22, 2021
I think this error occurs when anyone tries to count nested relations meaning that if someone has a condition similar to this -
Usertable havingsubscribersas a field that an array (came from a relation) and theUsertable is related toVideotable.When
Videotable is queried and we want to joinUsertable and also count thesubscribersfield.Something like this -
Here is the respective schema -
I loved prisma until I started to get these kind of errors, please prisma team help everyone out by resolving this issue.
As @subnomo also said that this occurs when we try to count nested relation. We definitely need this feature (typescript is also fine when I try to do this 😂 but we want prisma to be fine too).
Thanks.