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.

Error when running prisma+mongodb with connection string with no database name (using Azure Cosmos DB With Mongo API)

See original GitHub issue

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v15.11.0
OS darwin
Prisma Client 2.21.2
Query Engine query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d
Database undefined

Query

mutation {
  createOneStore(data: {
    name: "X"
    url: "X"
  }) {
    id
    createdAt
    updatedAt
    name
    url
  }
}

Logs

ne stderr  [query-engine/connectors/mongodb-query-connector/src/error.rs:28] &self = DriverError(  +3s
  prisma:engine stderr      Error {  
  prisma:engine stderr          kind: CommandError(  
  prisma:engine stderr              CommandError {  
  prisma:engine stderr                  code: 73,  
  prisma:engine stderr                  code_name: "InvalidNamespace",  
  prisma:engine stderr                  message: "Database name can\'t be empty.",  
  prisma:engine stderr                  labels: [],  
  prisma:engine stderr              },  
  prisma:engine stderr          ),  
  prisma:engine stderr          labels: [],  
  prisma:engine stderr      },  
  prisma:engine stderr  )  
  prisma:engine stdout  PANIC in query-engine/connectors/mongodb-query-connector/src/error.rs:104:63
not yet implemented  
  prisma:engine {
  prisma:engine   error: SocketError: other side closed
  prisma:engine       at Socket.onSocketEnd (/Users/luisrudge/code/prismamongo/node_modules/@prisma/client/runtime/index.js:25205:24)
  prisma:engine       at Socket.emit (node:events:390:22)
  prisma:engine       at Socket.EventEmitter.emit (node:domain:470:12)
  prisma:engine       at endReadableNT (node:internal/streams/readable:1307:12)
  prisma:engine       at processTicksAndRejections (node:internal/process/task_queues:81:21) {
  prisma:engine     code: 'UND_ERR_SOCKET'
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: Error: connect ECONNREFUSED 127.0.0.1:64078
  prisma:engine       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1137:16) {
  prisma:engine     errno: -61,
  prisma:engine     code: 'ECONNREFUSED',
  prisma:engine     syscall: 'connect',
  prisma:engine     address: '127.0.0.1',
  prisma:engine     port: 64078
  prisma:engine   }
  prisma:engine }  
  prisma:engine { cwd: '/Users/luisrudge/code/prismamongo/prisma' }  
  prisma:engine Search for Query Engine in /Users/luisrudge/code/prismamongo/node_modules/.prisma/client  
  plusX Execution permissions of /Users/luisrudge/code/prismamongo/node_modules/.prisma/client/query-engine-darwin are fine  +3s
  prisma:engine {
  prisma:engine   flags: [
  prisma:engine     '--enable-experimental=mongodb,mongodb',
  prisma:engine     '--enable-raw-queries',
  prisma:engine     '--port',
  prisma:engine     '64108'
  prisma:engine   ]
  prisma:engine }  
  prisma:engine stdout  Started http server on http://127.0.0.1:64108  
  prisma:engine Search for Query Engine in /Users/luisrudge/code/prismamongo/node_modules/.prisma/client  
  plusX Execution permissions of /Users/luisrudge/code/prismamongo/node_modules/.prisma/client/query-engine-darwin are fine  
  prisma:engine Client Version: 2.21.2  
  prisma:engine Engine Version: query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d  
  prisma:engine Active provider: mongodb  
  prisma:engine stderr  [query-engine/connectors/mongodb-query-connector/src/error.rs:28] &self = DriverError(  +1s
  prisma:engine stderr      Error {  
  prisma:engine stderr          kind: CommandError(  
  prisma:engine stderr              CommandError {  
  prisma:engine stderr                  code: 73,  
  prisma:engine stderr                  code_name: "InvalidNamespace",  
  prisma:engine stderr                  message: "Database name can\'t be empty.",  
  prisma:engine stderr                  labels: [],  
  prisma:engine stderr              },  
  prisma:engine stderr          ),  
  prisma:engine stderr          labels: [],  
  prisma:engine stderr      },  
  prisma:engine stderr  )  
  prisma:engine stdout  PANIC in query-engine/connectors/mongodb-query-connector/src/error.rs:104:63
not yet implemented  
  prisma:engine {
  prisma:engine   error: SocketError: other side closed
  prisma:engine       at Socket.onSocketEnd (/Users/luisrudge/code/prismamongo/node_modules/@prisma/client/runtime/index.js:25205:24)
  prisma:engine       at Socket.emit (node:events:390:22)
  prisma:engine       at Socket.EventEmitter.emit (node:domain:470:12)
  prisma:engine       at endReadableNT (node:internal/streams/readable:1307:12)
  prisma:engine       at processTicksAndRejections (node:internal/process/task_queues:81:21) {
  prisma:engine     code: 'UND_ERR_SOCKET'
  prisma:engine   }
  prisma:engine }  

Client Snippet

import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

async function main() {
  await prisma.$connect();

  // Create the first post
  await prisma.store.create({
    data: {
      name: "Test Store",
      url: "https://test.com",
    },
  });

  // Read all the posts
  const stores = await prisma.store.findMany();

  // Log our posts showing nested structures
  console.dir(stores, { depth: Infinity });
}

main()
  .catch(console.error)
  .finally(() => prisma.$disconnect());

Schema

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

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

model Store {
  id        String   @id @default(dbgenerated()) @map("_id") @db.ObjectId
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name      String
  url       String
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
xdavecommented, Apr 23, 2021

It’s technically possible to connect without selecting a database in the connection string. Other mongodb clients support selecting different databases inside of the same connection.

For many, this could be a required use case for multi-tenant applications.

0reactions
janpiocommented, Feb 24, 2022

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot common errors in Azure Cosmos DB's API for ...
Code Error Description 13 Unauthorized The request lacks the permissions to complete. 67 CannotCreateIndex The request to create an index can't be completed. 115 CommandNotSupported The...
Read more >
Unable to connect to Mongo DB with Azure Cosmos DB
Check to be Consider: Connection string from Azure COSMOS DB Environment. MongoDB Driver Version private string userName = "FILLME"; ...
Read more >
MongoDB database connector - Prisma
Refer to the MongoDB connection string documentation for a complete list of connection string arguments. There are no Prisma-specific arguments. Using ObjectId.
Read more >
prisma mongodb how to deal with schema update - You.com
Environment & setup. OS: Mac OS; Database: MongoDB (using Azure CosmosDB with Mongo API); Node.js version: 15.11.0; Prisma ...
Read more >
Tip: Connecting to Azure Cosmos DB MongoDB API using the ...
Println("connected!") } To test, just set the connection string and run the program export MONGODB_CONNECTION_STRING=<copy-paste from azure ...
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