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.

Data Proxy: Client network socket disconnected

See original GitHub issue

Bug description

I’m using Mongodb Cloud with the Prisma data proxy.

Every now and then I’ll get the following error: Client network socket disconnected before secure TLS connection was established in production.

It seems to only happen when using the client functions runCommandRaw or aggregateRaw.

The connection string I’ve entered for the data proxy looks like this: mongodb+srv://<user>:<pass>@<host>/db?maxPoolSize=500

You can see the only option is maxPoolSize. Maybe the proxy requires retryWrites to set and true?

How to reproduce

Expected behavior

No response

Prisma information

Prisma function:

 await prisma.$runCommandRaw({
    update: 'QuotaUsage',
    updates: [
      {
        q: {
          month: new Date().getUTCMonth(),
          year: new Date().getUTCFullYear(),
          userId: { $oid: userId },
        },
        u: {
          $inc: {
            usage: quotaUsage,
          },
        },
      },
    ],
  });

Relevant schema part

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

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

...

model QuotaUsage {
  id     String @id @default(auto()) @map("_id") @db.ObjectId
  userId String @db.ObjectId
  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
  usage  Int    @default(0)
  month  Int
  year   Int

  @@unique([userId, month, year])
}

Environment & setup

  • OS: Vercel Serverless (Ubuntu?)
  • Database: MongoDB 5
  • Node.js version: 14

Prisma Version

prisma                  : 3.12.0
@prisma/client          : 3.12.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio                  : 0.459.0
Preview Features        : dataProxy

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
millspcommented, Jun 7, 2022

Hey everyone, I just wanted to let you know that we shipped prisma@3.15.0 with a RequestError that will be automatically retried in case of network errors. Only if the error is not recoverable after a few retries with backoff, it will throw an exception.

0reactions
janpiocommented, Apr 15, 2022

No, Heroku should not be a problem in any way for Prisma’s Data Proxy as far as I am aware.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - "Client network socket disconnected before secure ...
Click On "Connection"; Go to LAN Settings; Uncheck "Use Proxy Server for LAN ...." It should work but the permanent solution is to...
Read more >
Error work with proxy. Client network socket disconnected ...
Coding example for the question Error work with proxy. Client network socket disconnected before secure TLS connection was established-node.js.
Read more >
Error: Client network socket disconnected before ... - Laracasts
Hi all, I using sanctum api, and trying to send requests but the postman shows and an error as : Error: Client network...
Read more >
Error: Client network socket disconnected ... - VTEX Community
Press the Windows Key; Search For Internet Options; Click on “Internet Options”; Click On “Connection”; Go to LAN Settings; Uncheck “Use Proxy ......
Read more >
Client network socket disconnected before secure ... - MongoDB
I am using MongoClient in NodeJs to carry out Db operations, I am running into connection and db caching issues, I'm getting the...
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