Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection timeout 10000ms when upgraded mongoose from 7.4.5 to 8.7.1 #14971

Open
1 task done
sukhminderx opened this issue Oct 17, 2024 · 1 comment
Open
1 task done
Labels
help wanted help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Milestone

Comments

@sukhminderx
Copy link

Prerequisites

  • I have written a descriptive issue title

Mongoose version

8.7.1

Node.js version

20.x

MongoDB version

6.9

Operating system

None

Operating system version (i.e. 20.04, 11.3, 10)

No response

Issue

Last night, I upgraded my mongodb and mongoose from versions 5.8.1 to 6.9 and. 7.4.5 to 8.7.1 respectively.

I tested on my local. Everything worked fine. I promoted the changes to test env - AWS amplify - things were fine. Then, I moved the changes to production.

My db is hosted on mongo atlas serverless cluster.

On production, sometimes same queries will work fine but other times give timeout error with 10000ms. I mean same queries behaving differently.

I have been scratching my head because both test and prod env are exactly similar except that prod is connected to my domain name.
Please assist if someone has knowledge about this.

sharing my connection code and one query that fails/passes abruptly.

import { ServerApiVersion } from "mongodb";
import mongoose from "mongoose";

const uri = process.env.MONGODB_URI as string;


const connection: {
  isConnected?: boolean;
} = {};

const dbConnect = async () => {
  if (connection.isConnected) return;
  mongoose.set("strictQuery", false);
  const db = await mongoose.connect(uri);

  connection.isConnected = Boolean(db.connections[0].readyState);
};
export default dbConnect;
export async function GET(req: Request) {
  try {
    await apiHandler(req, "");
    const countries: any = await Countries.find({}).exec();
    return NextResponse.json(countries, { status: 200 });
  } catch (error: any) {
    console.log("wb saas: countries");
    console.log(
      typeof error !== "string"
        ? error.message
          ? error.message
          : (error || {}).toString()
        : error
    );
    return errorHandler(error);
  }
}
@sukhminderx sukhminderx added help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Oct 17, 2024
@vkarpov15 vkarpov15 added this to the 8.7.3 milestone Oct 20, 2024
@garethlowriehive
Copy link

garethlowriehive commented Oct 22, 2024

We're also experiencing a very similar issue.

Using MongoDB Server 8.0 in Atlas and locally in Docker.
Node: 20.11.1
Mongoose 8.7.1

Everything works intermittently, but lots of buffering error across lots of different find’s and aggregates in all of our microservices.

Buffering timed out after 10000ms

Posted about it here: https://www.mongodb.com/community/forums/t/buffering-timed-out-after-10000ms-8-7-0-mongoose-node-20-10-0/299932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Projects
None yet
Development

No branches or pull requests

3 participants