olexnzarov / telegraf-session-mongodb

MongoDB session middleware for Telegraf
25 stars 14 forks source link

Cannot read property 'enter' of undefined #13

Closed jackkru69 closed 3 years ago

jackkru69 commented 3 years ago

mogoose(^6.0.5) with telegraf-session-mongodb(^2.0.2), telegraf(^4.4.2) (node:12494) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'enter' of undefined

function setupMongoose(bot: Telegraf<BotContext>) {
  // Connect to the db
  mongoose
    .connect(MONGO_URL, {
      // DB gets huge, so setting up custom timeouts
      socketTimeoutMS: 10000,
      connectTimeoutMS: 50000,
    })
    .then((client) => {
      bot.use(
        mongodbSession(client.connection.db, {
          sessionName: 'session',
          collectionName: 'sessions',
        }),
      );
    });
}