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

MongooseError: Operation settings.findOne() buffering timed out after 10000ms #158

Closed
princedotorg opened this issue Dec 19, 2023 · 11 comments

Comments

@princedotorg
Copy link

MongooseError: Operation settings.findOne() buffering timed out after 10000ms

@jeffreyscarpenter
Copy link
Contributor

Thanks for the report. Could you provide a bit more information? Running against Astra or your own installation? If own installation, what version? Can you describe the workload a bit? You can also reach out on Discord for higher bandwidth conversation.

@princedotorg
Copy link
Author

I simply installed stargate-mongoose@latest using npm install, I were using Datastax AstraDB

@princedotorg
Copy link
Author

const mongoose = require('mongoose');
const stargate_mongoose = require('stargate-mongoose');
const driver = stargate_mongoose.driver;
mongoose.setDriver(driver);
mongoose.set('autoIndex', false);
mongoose.connect('https://xxxxxxxxxx-us-east-2.apps.astra.datastax.com/api/json/v1/default_keyspace?applicationToken=AstraCS:xxx',{
'isAstra': true
});
mongoose.set('debug',true)
Object.values(mongoose.connection.models).map(Model => Model.init());
mongoose.set('debug',true)
Object.values(mongoose.connection.models).map(Model => Model.init());

@vkarpov15
Copy link
Collaborator

How are you defining your settings model? And how are you calling findOne()?

@princedotorg
Copy link
Author

princedotorg commented Dec 28, 2023

const mongoose = require('mongoose');

const settingsSchema = new mongoose.Schema({
  serverID: { type: String, required: true },
  
  staffRoleId: { type: String, required: true },
  
  paymentChannelId: { type: String, required: false},
  
  remindersChannelId: { type: String, required: false},
  
  logsChannelId: { type: String, required: false},
  
  gawDonoChannel: { type: String, required: false },
  
  heistDonoChannel: { type: String, required: false},
  
  eventDonoChannel: { type: String, required: false},
  
  serverDonoChannel: { type: String, required: false},
  
 donoAnnounceChannel:{ type: String, required: false},
 
 donorRoles: { type: Object, required: false  },
 payoutQchannel: { type: String, required: false },
 
  payoutXchannel: { type: String, required: false },
  
  payoutDchannel: { type: String, required: false },
  
  autoroles: { type: Array, required: false },
  
  donoMulti: { type: Object, required: false },
  
  eventChannel: { type: String, required: false},
  
  gawChannel: { type: String, required: false},
  
  heistChannel: { type: String, required: false},
  
  lobby: { type: String, required: false },
  
 minimumAmount: { type: Number, required: false, default:1000 },
 
  badges: { type: Object, required: false },
  
  slogans: { type: Object, required: false, default: {
    'Normie': 1000
  } },
  
  eping: { type: String, required: false },
  
  gping: { type: String, required: false },
  
  hping: { type: String, required: false },
  
  eman: { type: String, required: false },
  
  gman: { type: String, required: false },
  
  pman: { type: String, required: false },
  
  isPartner: { type: Boolean, required: false, default: false },
  dropsen: { type: Boolean, required: true, default: false },
  
  gen: { type: Boolean, required: true, default: false },
  pen: { type: Boolean, required: true, default: false },
  epen: { type: Boolean, required: true, default: false },
  donoen: { type: Boolean, required: true, default: false },
  isPremium: { type: Boolean, required: true, default: false },
  Since: { type: String, required: false, default: Math.floor(new Date().getTime()/1000) },
  vote_tracker_en: { type: Boolean, required: false, default: false },
  webhookEn: { type: Boolean, required: false, default: false },
  webhook: { type: String, required: false, default: '' },
  webhookHeaders: { type: Object, required: false, default: {
  } },
  webhookMethod: { type: String, required: false, default: 'POST' },
  webhookMode: { type: String, required: false, default: 'CUSTOM' },
  webhookJWT: { type: Boolean, required: false, default: false },
  beta: { type: Boolean, required: true, default: false },
  setup: { type:  Boolean,required: true,  default: false },
  amarien: { type: Boolean,  required:true, default: false },
  supportKey: { type: String, required: true },
  dropItems: { type: Array, required: false },
  bypass: { type: Array, required: false , default: []},
  blacklist: { type: Array,  required: false, default: []},
  autoroles_toggle: { type: Boolean,required: false, default: false }
  // More items
});

module.exports = mongoose.model('Settings', settingsSchema);

@princedotorg
Copy link
Author

I export and use my model from diff file

@vkarpov15
Copy link
Collaborator

And how are you calling findOne()? The error message suggests you're calling Settings.findOne() somewhere

@princedotorg
Copy link
Author

Simply i require my model using const Settings = require("./path/to/model.js")

async blocks....
await Settings.findOne({...})
...

@vkarpov15
Copy link
Collaborator

I'm unable to repro, the following script works correctly against my Astra cluster. Can you please modify the following script to demonstrate the issue you're seeing?

'use strict';

const mongoose = require('mongoose');
const stargate_mongoose = require('stargate-mongoose');
const driver = stargate_mongoose.driver;
mongoose.setDriver(driver);
mongoose.set('autoIndex', false);

mongoose.connect(process.env.ASTRA_CONNECTION_STRING, {
'isAstra': true
});

mongoose.set('debug',true)
Object.values(mongoose.connection.models).map(Model => Model.init());
mongoose.set('debug',true)
Object.values(mongoose.connection.models).map(Model => Model.init());

const settingsSchema = new mongoose.Schema({
  serverID: { type: String, required: true },
  
  staffRoleId: { type: String, required: true },
  
  paymentChannelId: { type: String, required: false},
  
  remindersChannelId: { type: String, required: false},
  
  logsChannelId: { type: String, required: false},
  
  gawDonoChannel: { type: String, required: false },
  
  heistDonoChannel: { type: String, required: false},
  
  eventDonoChannel: { type: String, required: false},
  
  serverDonoChannel: { type: String, required: false},
  
 donoAnnounceChannel:{ type: String, required: false},
 
 donorRoles: { type: Object, required: false  },
 payoutQchannel: { type: String, required: false },
 
  payoutXchannel: { type: String, required: false },
  
  payoutDchannel: { type: String, required: false },
  
  autoroles: { type: Array, required: false },
  
  donoMulti: { type: Object, required: false },
  
  eventChannel: { type: String, required: false},
  
  gawChannel: { type: String, required: false},
  
  heistChannel: { type: String, required: false},
  
  lobby: { type: String, required: false },
  
 minimumAmount: { type: Number, required: false, default:1000 },
 
  badges: { type: Object, required: false },
  
  slogans: { type: Object, required: false, default: {
    'Normie': 1000
  } },
  
  eping: { type: String, required: false },
  
  gping: { type: String, required: false },
  
  hping: { type: String, required: false },
  
  eman: { type: String, required: false },
  
  gman: { type: String, required: false },
  
  pman: { type: String, required: false },
  
  isPartner: { type: Boolean, required: false, default: false },
  dropsen: { type: Boolean, required: true, default: false },
  
  gen: { type: Boolean, required: true, default: false },
  pen: { type: Boolean, required: true, default: false },
  epen: { type: Boolean, required: true, default: false },
  donoen: { type: Boolean, required: true, default: false },
  isPremium: { type: Boolean, required: true, default: false },
  Since: { type: String, required: false, default: Math.floor(new Date().getTime()/1000) },
  vote_tracker_en: { type: Boolean, required: false, default: false },
  webhookEn: { type: Boolean, required: false, default: false },
  webhook: { type: String, required: false, default: '' },
  webhookHeaders: { type: Object, required: false, default: {
  } },
  webhookMethod: { type: String, required: false, default: 'POST' },
  webhookMode: { type: String, required: false, default: 'CUSTOM' },
  webhookJWT: { type: Boolean, required: false, default: false },
  beta: { type: Boolean, required: true, default: false },
  setup: { type:  Boolean,required: true,  default: false },
  amarien: { type: Boolean,  required:true, default: false },
  supportKey: { type: String, required: true },
  dropItems: { type: Array, required: false },
  bypass: { type: Array, required: false , default: []},
  blacklist: { type: Array,  required: false, default: []},
  autoroles_toggle: { type: Boolean,required: false, default: false }
  // More items
});

const Settings = mongoose.model('Settings', settingsSchema);

run().catch(err => {
  console.error(err);
  process.exit(-1);
});

async function run() {
  await Settings.findOne();
  console.log('Done');
  process.exit(0);
}

@princedotorg
Copy link
Author

This worked, Maybe because you used proper async blocks which I don't use in some functions. Anyways you should consider upgrading mongoose to 8.x.x and support http2

@vkarpov15
Copy link
Collaborator

Mongoose 8 support was merged in #154, and http2 support is in review with #153

@jeffreyscarpenter jeffreyscarpenter changed the title Err MongooseError: Operation settings.findOne() buffering timed out after 10000ms Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants