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.

[wrong error msg]: Transactions are not supported by this deployment

See original GitHub issue

Bug description

When I use Prisma to connect to MongoDB replica set, there seems to be a problem. My connection URL is mongodb://root:prisma@localhost:27017/prisma-mongo. It can’t connect my mongodb. I received an error like that.

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


  Error in connector: Database error. error code: unknown, error message: Transactions are not supported by this deployment
    at cb (E:\Desktop\tessttttttt\prisma-examples\databases\mongodb\node_modules\@prisma\client\runtime\index.js:36378:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  clientVersion: '2.29.1'
}

After that, I researched and changed my connection URL to mongodb://root:prisma@localhost:27017/prisma-mongo?authSource=admin&retryWrites=true&w=majority, it works fine. I realized that the error was caused by my connection missing authSource=admin.

Docker image run Mongo replica set here.

How to reproduce

  1. Run Mongo replica set on Docker
  2. Create schema
  3. Run npx prisma generate
  4. Run node demo.js
  5. See error

Expected behavior

Maybe I should be received an authentication error instead of transactions are not supported by this deployment. Because my connection URL is missing authSource=admin which is not related to transaction in db.

Prisma information

datasource db {
  provider = "mongodb"
  url      = env("mongodb://root:prisma@localhost:27017/prisma-mongo")
}

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

model User {
  id        String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  createdAt DateTime @default(now())
  firstName String
  lastName  String?
  email     String   @unique
}

Environment & setup

  • OS: Windows 10
  • Database: MongoDB
  • Node.js version: v12.18.4
  • Docker version: 19.03.13, build 4484c46d9d

Prisma Version

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
janpiocommented, Aug 27, 2021

The problem is that this message comes from Mongo directly. Seems that without authSource=admin the database indeed does not support transactions, but unfortunately does not mention that in the error message.

1reaction
duyquoc1508commented, Mar 23, 2022

@janpio @pantharshit00 Sorry you can’t reproduce the exact error I got, but I’m still getting the error as mentioned if the database connection string is missing authSource=admin. Here is the docker-compose.yml file that I used to create a MongoDB replica instance. Hope it can help you to reproduce the error

version: '3.7'
services:
  mongodb_container:
    # This image automatically creates a replica set required for transactions
    image: prismagraphql/mongo-single-replica:4.4.3-bionic
    container_name: mongo-replica
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: prisma
    ports:
      - '37017:27017'
      - '27017:27017'
    volumes:
      - ./.docker/mongodb/initdb.d/:/docker-entrypoint-initdb.d

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make the MongoDB Replica Set Requirement Optional in ...
Problem MongoDB only allows you to start a transaction on a replica set. ... [wrong error msg]: Transactions are not supported by this...
Read more >
This MongoDB deployment does not support retryable writes ...
When I hit this api on my local environment, I get following error: MongoError: This MongoDB deployment does not support retryable writes.
Read more >
Retryable Writes — MongoDB Manual
The write operations inside the transaction are not individually retryable, regardless of value of retryWrites . For more information on transactions, see ...
Read more >
You receive an error message when you run a SQL Server ...
The application is trying to load a version of Compact that is incompatible with the version that is installed on the computer. Incorrect...
Read more >
Understanding and resolving MetaMask error codes
'4200': { standard: 'EIP-1193', message: 'The requested method is not supported by this Ethereum provider.', },.
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