prisma: Prisma MongoDB Connector findMany query failing (CursorNotFound)

Bug description

Querying a big collection, or getting all documents from a big collection results into a connection error thrown by Prisma. Error Stack:

Failed to connect to the database. PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: 
Invalid `prisma.verifiedBots.findMany()` invocation:

  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Command failed (CursorNotFound): cursor id 6919368312204108651 not found)" } })

Possible related Stack Overflow thread(s):

How to reproduce

  1. Connect to the MongoDB Connector
  2. Query a big collection (the collection on hand contains about 400 documents, with varying document sizes) using findMany()
  3. See error

Expected behavior

Prisma will throw PrismaClientUnknownRequestError2 Error Stack:

Failed to connect to the database. PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: 
Invalid `prisma.verifiedBots.findMany()` invocation:

  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Command failed (CursorNotFound): cursor id 6919368312204108651 not found)" } })

Prisma information

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

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

model dataset {
  id                   String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  clientid             String   @unique
  data                 String   @default("")
}

Environment & setup

  • OS: Windows 10 Pro 21H1
  • Database: MongoDB 5.0
  • Node.js version: v16.5.0

Prisma Version

prisma               : 2.27.0
@prisma/client       : 2.27.0
Current platform     : windows
Query Engine         : query-engine cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt cdba6ec525e0213cce26f8e4bb23cf556d1479bb (at node_modules\@prisma\engines\prisma-fmt-windows.exe)  
Default Engines Hash : cdba6ec525e0213cce26f8e4bb23cf556d1479bb
Studio               : 0.410.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 9
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Hey folks,

I spent some time investigating this issue today. I’m now waiting for confirmation from the MongoDB folks but it seems that the error comes from the Rust driver itself.

I created an issue on their repo that you can find here: https://github.com/mongodb/mongo-rust-driver/issues/482

I’ll try to keep you up-to-date with further news once I know more

any update on this? Experiencing the same issue in 3.1.1

I can confirm the bug fix will be included in the next release.

@redbaron76 The next release should be today.

Thanks for the reports folks 🙏

In all my tests, findMany() seems to fail in any subsequent query on the same dataset when applying select: {...} clause which relates to some collections with 100+ records inside. It doesn’t matter if cursor: {id: ...} is present or not in the query. Maybe this helps.

Hey @redbaron76, yes the reason for that problem is laid out in this issue https://github.com/mongodb/mongo-rust-driver/issues/482

On that note, a fix on the MongoDB Rust driver was just pushed, effectively closing https://github.com/mongodb/mongo-rust-driver/issues/482. I’ve been told a new version of the driver would be released tomorrow, meaning that this issue might be fixed in time for the next Prisma release.

Seems like this is the same error I’ve been describing here: https://github.com/prisma/prisma/issues/9650 I’m not yet closing my issue since I’m not sure it’s really a duplicate but wanted to at least mention this here.

Can confirm the query works normally up to v2.26.0. Only fails in v2.27.0 and v2.28.0

Same error here. The above error occurs when querying 100+ objects from a collection with 500 objects

True. But I think is something related explicitly to MongoDB implementation which is a topic relatively new in the Prisma world and still in experimental stage.

Hate to be that guy whining on Github issues, but the fact that there’s be no comment in 3 months from core developers on such major issue is kinda frightening.

Still present in the brand new 3.2.0 release.

My implementation fails when I start a cursor-based infinite pagination.

I have the same issue, Prisma 3.1.1