question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoDB ConnectorError: `Command failed (IllegalOperation): This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)`

See original GitHub issue

Bug description

When I use Prisma to connect to MongoDB, there seems to be a problem. My connection URL is mongodb://localhost:27017/dao, it works well in 2.26.0. But after that version, like 2.27.0 or the latest version, It can’t connect my mongodb. As the information indicates, i make URL like mongodb://localhost:27017/dao?retryWrites=false, It also like that.

PrismaClientUnknownRequestError3 [PrismaClientUnknownRequestError]: 
Invalid `prisma.user.create()` invocation:

  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Command failed (IllegalOperation): This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)" } })
    at cb (/Users/rain/WhiteMatrix/demo/prisma/dist/runtime/index.js:35947:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (/Users/rain/WhiteMatrix/demo/demo/demo.js:7:17) {
  clientVersion: '2.29.0'
}

How to reproduce

  1. Create schema
  2. RUN yarn prisma generate
  3. Run node demo.js
  4. See error

Expected behavior

No response

Prisma information

datasource db {
  provider = "mongodb"
  url      = "mongodb://localhost:27017/dao?retryWrites=false"
}

generator client {
  provider        = "prisma-client-js"
  // MacOS Alpine Ubuntu18/Debian10+ Centos7+
  binaryTargets   = ["darwin", "linux-musl", "debian-openssl-1.1.x", "rhel-openssl-1.0.x"]
  previewFeatures = ["mongodb", "referentialActions"]
  output          = "./dist"
}

enum UserRole {
  Admin
  Member
}

model User {
  id       String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  username String   @unique
  passwd   String
  role     UserRole
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
}

Environment & setup

  • OS: Mac OS
  • Database: MongoDB 5
  • Node.js version: v16.4.0

Prisma Version

prisma               : 2.29.0
@prisma/client       : 2.29.0
Current platform     : darwin
Query Engine         : query-engine 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt 1be4cd60b89afa04b192acb1ef47758a39810f3a (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 1be4cd60b89afa04b192acb1ef47758a39810f3a
Studio               : 0.419.0
Preview Features     : mongoDb, referentialActions

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
pantharshit00commented, Aug 18, 2021

Related to #8266

You currently need a mongodb instance with replica set in order to use Prisma. You can use the free tier atlas cluster or the mongodb docker image.

4reactions
matthewmuellercommented, Feb 18, 2022

This is due to the replicaSet not being configured. We’re working on docs for this and a better error message, but for now either:

Read more comments on GitHub >

github_iconTop Results From Across the Web

This MongoDB deployment does not support retryable writes ...
Please add retryWrites =false to your connection string. When I hit this api on remote environment, then it runs fine. I am using...
Read more >
Retryable Writes — MongoDB Manual
Prior to MongoDB 4.2, MongoDB retryable writes did not support retrying upserts which failed due to duplicate key errors. Diagnostics. The serverStatus command, ......
Read more >
MongoDB deployment does not support retryable writes - Reddit
hello, I can't use Prisma studio with a mongodb deployment. Prisma return to me an error : Message: Invalid \prisma.user.create()` ...
Read more >
MongoDB 3.6 Retryable Writes . . . Retryable Writes - Percona
Generally, you enable the use of Retryable Writes by adding the 'retryWrites=' flag to your MongoDB connection string that is passed to your...
Read more >
Lightning Fast Guide on Prisma MongoDB Connection using ...
... "Command failed (IllegalOperation): This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found