Improve error message when client fails to connect to a mongodb database
See original GitHub issueHi Prisma Team! My Prisma Client just crashed. This is the report:
Versions
Name | Version |
---|---|
Node | v14.16.1 |
OS | debian-openssl-1.1.x (WSL) |
Prisma Client | 2.21.2 |
Query Engine | query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d |
Database | undefined |
Query
query {
findManyusers {
id
username
collapsed
darktheme
}
}
Logs
isma:engine stdout Started http server on http://127.0.0.1:44611
prisma:engine Search for Query Engine in /home/jhemphill/data-model/node_modules/.prisma/client
plusX Execution permissions of /home/jhemphill/data-model/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x 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( +30s
prisma:engine stderr Error {
prisma:engine stderr kind: ServerSelectionError {
prisma:engine stderr message: "Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: localhost:27017, Type: Unknown, Error: Connection refused (os error 111) }, ] }",
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:115:75
not yet implemented
prisma:engine {
prisma:engine error: SocketError: other side closed
prisma:engine at Socket.onSocketEnd (/home/jhemphill/data-model/node_modules/@prisma/client/runtime/index.js:25205:24)
prisma:engine at Socket.emit (events.js:327:22)
prisma:engine at Socket.EventEmitter.emit (domain.js:467:12)
prisma:engine at endReadableNT (internal/streams/readable.js:1327:12)
prisma:engine at processTicksAndRejections (internal/process/task_queues.js:80:21) {
prisma:engine code: 'UND_ERR_SOCKET'
prisma:engine }
prisma:engine }
prisma:engine { cwd: '/home/jhemphill/ciwi/data-model/prisma' }
prisma:engine Search for Query Engine in /home/jhemphill/data-model/node_modules/.prisma/client
plusX Execution permissions of /home/jhemphill/data-model/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine +30s
prisma:engine {
prisma:engine flags: [
prisma:engine '--enable-experimental=microsoftSqlServer,mongodb,mongodb',
prisma:engine '--enable-raw-queries',
prisma:engine '--port',
prisma:engine '42905'
prisma:engine ]
prisma:engine }
prisma:engine stdout Started http server on http://127.0.0.1:42905
prisma:engine Search for Query Engine in /home/jhemphill/data-model/node_modules/.prisma/client
plusX Execution permissions of /home/jhemphill/data-model/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x 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( +30s
prisma:engine stderr Error {
prisma:engine stderr kind: ServerSelectionError {
prisma:engine stderr message: "Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: localhost:27017, Type: Unknown, Error: Connection refused (os error 111) }, ] }",
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:115:75
not yet implemented
prisma:engine {
prisma:engine error: SocketError: other side closed
prisma:engine at Socket.onSocketEnd (/home/jhemphill/data-model/node_modules/@prisma/client/runtime/index.js:25205:24)
prisma:engine at Socket.emit (events.js:327:22)
prisma:engine at Socket.EventEmitter.emit (domain.js:467:12)
prisma:engine at endReadableNT (internal/streams/readable.js:1327:12)
prisma:engine at processTicksAndRejections (internal/process/task_queues.js:80:21) {
prisma:engine code: 'UND_ERR_SOCKET'
prisma:engine }
prisma:engine }
Client Snippet
import { PrismaClient } from '.prisma/client/index.js';
const prisma = new PrismaClient();
async function main() {
const allUsers = await prisma.users.findMany();
console.log(allUsers);
}
main()
.catch((e) => {
throw e;
})
.finally(async () => {
await prisma.$disconnect();
});
Schema
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["microsoftSqlServer", "mongodb"]
}
model users {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
username String @unique
collapsed String
darktheme String
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Troubleshoot Connection Issues — MongoDB Atlas
Atlas allows client connections only from IP addresses and CIDR address ranges ... an error stating connection refused because too many open connections...
Read more >I suddenly became unable to connect ...
I have been using mongoDb for quite a while. And only a few days ago I was able to dump mongodb. I usually...
Read more >Having trouble connecting to MongoClient before calling ...
The error is suggesting that the program is invoking the mongo.db("main") before the connecting to the server at mongo.connect(...) . This is ...
Read more >let MongoDB return errors instead of preventing them
For performance purpose, would it be a bad practice to let mongodb handle the errors instead of trying to avoid them in advance?...
Read more >Improved Error Messages for Schema Validation in ...
Schema validation ease-of-use will be significantly improved by generating descriptive error messages whenever an operation fails validation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Its not a panic now in version
2.23.0-dev.37
but it is still ugly. We should improve it:Ok thanks. Now we know the circumstances, still a bug as you did not get a good error message but the Engine panicked instead. We can fix that.