MongooseError:操作 `users.findOne()` 缓冲在 Next.js 应用程序 10000 毫秒后超时

问题描述 投票:0回答:1

我在 Next.js 应用程序中遇到“MongooseError:操作 users.findOne() 缓冲在 10000 毫秒后超时”错误。我正在使用 Mongoose (^8.2.2) 连接到 MongoDB 数据库。

我正在使用 Next.js 14+

采取的故障排除步骤:

验证 MongoDB 连接字符串是否准确并包含所有凭据。 确认 MongoDB 服务器正在运行且可访问。 我将访问IP更改为任何地方。并且错误始终出现。

控制台

 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.proces

猫鼬根文件:

import mongoose from 'mongoose';

let isConnected: boolean = false


export const connectToDataBase = async () => {
    mongoose.set('strictQuery', true)


    if (!process.env.MONGODB_URL) {
        return console.log('missing MONGODB_URL');
    }
    if (isConnected) {
        return console.log('mongoDB is connected already !');
    }
    try {
        await mongoose.connect(process.env.MONGODB_URL, {
            dbName: 'codeFlow',
        })
        isConnected = true
        console.log('mongoDb is connected');
    } catch (error) {
        console.log('mongoDB connecttion failed', error);
        isConnected = false
    }
}

用户模型

import { Schema, model, models, Document } from "mongoose";

export interface IUser extends Document {
    clerkId: string
    name: string
    username: string
    email: string
    password?: string
    bio?: string
    picture: string
    location?: string
    portfolioWebsite?: string
    reputaion?: number
    saved: Schema.Types.ObjectId[]
    joinAt: Date
}

const UserSchema = new Schema({
    clerkId: { type: String, required: true },
    name: { type: String, required: true },
    username: { type: String, required: true, unique: true },
    email: { type: String, required: true, unique: true },
    password: { type: String, },
    bio: { type: String },
    picture: { type: String, required: true },
    location: { type: String },
    portfolioWebsite: { type: String },
    reputation: { type: Number, default: 0 },
    saved: [{ type: Schema.Types.ObjectId, ref: 'Question' }],
    joinAt: { type: Date, default: Date.now },

});


const User = models.User || model('User', UserSchema)

export default User


用户操作

import { Schema, model, models, Document } from "mongoose";

export interface IUser extends Document {
    clerkId: string
    name: string
    username: string
    email: string
    password?: string
    bio?: string
    picture: string
    location?: string
    portfolioWebsite?: string
    reputaion?: number
    saved: Schema.Types.ObjectId[]
    joinAt: Date
}

const UserSchema = new Schema({
    clerkId: { type: String, required: true },
    name: { type: String, required: true },
    username: { type: String, required: true, unique: true },
    email: { type: String, required: true, unique: true },
    password: { type: String, },
    bio: { type: String },
    picture: { type: String, required: true },
    location: { type: String },
    portfolioWebsite: { type: String },
    reputation: { type: Number, default: 0 },
    saved: [{ type: Schema.Types.ObjectId, ref: 'Question' }],
    joinAt: { type: Date, default: Date.now },

});


const User = models.User || model('User', UserSchema)

export default User


getUserById
的召唤: 我使用了在数据库中创建的虚拟用户的 userId

import Question from "@/components/forms/Question"
import { getUserById } from "@/lib/actions/user.action"
import { auth } from "@clerk/nextjs"
import { redirect } from "next/navigation"


const Page = async () => {
  //const {userId} = auth()
  const userId = '123456'

  if (!userId) redirect('/sign-in')
  

  const mongoUser =  await getUserById({userId})

  console.log(mongoUser);

  return (
    <div>
      <h1 className=" h1-bold text-dark100_light900">Ask a question</h1>
      <div className="mt-8">
        <Question />
      </div>
    </div>
  )
}

export default Page

详细控制台错误

 ✓ Compiled in 308ms (870 modules)
connecting to mongoDB....
mongoDb is connected
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:162241)    at usePathname (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/navigation.js:121:34)
    at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:161:50)
    at au (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:10446)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:15122
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46505)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:58612
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59270
    at aA (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59278)
    at Timeout._onTimeout (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:6939)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:162241)    at usePathname (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/navigation.js:121:34)
    at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:161:50)
    at au (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:10446)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:15122
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46505)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:58612
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59270
    at aA (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59278)
    at Timeout._onTimeout (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:6939)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  page: '/ask-questions'
}
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
mongoDB connecttion failed Error: querySrv ETIMEOUT _mongodb._tcp.codeflow.ffodztu.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:275:17)
    at QueryReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: undefined,
  code: 'ETIMEOUT',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.codeflow.ffodztu.mongodb.net'
}
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:162241)    at usePathname (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/navigation.js:121:34)
    at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:161:50)
    at au (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:10446)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:15122
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46505)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:58612
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59270
    at aA (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59278)
    at Timeout._onTimeout (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:6939)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ TypeError: Cannot read properties of null (reading 'useContext')
    at t.useContext (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:162241)    at usePathname (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/navigation.js:121:34)
    at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:161:50)
    at au (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:10446)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:15122
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46505)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at ab (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:11808)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16871
    at aw (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:16908)
    at a_ (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49776)
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:58612
    at C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59270
    at aA (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:59278)
    at Timeout._onTimeout (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:6939)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  page: '/ask-questions'
}
 ✓ Compiled in 1242ms (869 modules)
connecting to mongoDB....
 ✓ Compiled in 1655ms (869 modules)
connecting to mongoDB....
mongoDb is connected
mongoDB connecttion failed Error: querySrv ETIMEOUT _mongodb._tcp.codeflow.ffodztu.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:275:17)
    at QueryReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: undefined,
  code: 'ETIMEOUT',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.codeflow.ffodztu.mongodb.net'
}
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ○ Compiling /_error ...
 ✓ Compiled /_error in 655ms (1557 modules)
 ✓ Compiled in 2.9s (1570 modules)
connecting to mongoDB....
connecting to mongoDB....
mongoDb is connected
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.
MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
 ⨯ Internal error: MongooseError: Operation `users.findOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\User\Desktop\saidPath\Next.js\next-dash\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:23)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
digest: "3887188482"
mongoDB connecttion failed Error: querySrv ETIMEOUT _mongodb._tcp.codeflow.ffodztu.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:275:17)
    at QueryReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: undefined,
  code: 'ETIMEOUT',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.codeflow.ffodztu.mongodb.net'
}

我希望获得具有提供的 id 的用户对象!

node.js typescript mongodb mongoose next.js
1个回答
0
投票

您遇到的错误可能是由以下原因引起的:

  1. 确保您的连接处于活动状态且可运行。
  2. 验证您的 IP 地址是否具有必要的访问权限。您可以通过导航到“数据服务”选项卡,选择左侧的“安全”,然后访问“网络访问”来完成此操作。从那里,您可以添加您的 IP 地址并包含“0.0.0.0/0”以授予来自任何网络地址的访问权限。
© www.soinside.com 2019 - 2024. All rights reserved.