title: passport.js Error: Failed to serialize user into session
body: <p><strong>I am using Nodejs Mongoose here But when i Try to replace Callback to promise It Gives me an error (Failed to serialize user into session) What should I do ?</strong></p>
  <p>I'm using passport.serializeUser and passport.deserializeUser but it gives this error</p>
  <pre><code>    const passport = require('passport');
  const DiscordStrategy = require('passport-discord');
  const User = require('../database/schemas/User');
  
  passport.serializeUser((user, done) =&gt; {
      done(null, user.discordid)
  })
  
  passport.deserializeUser(async (discordId, done) =&gt; {
      try {
          const user = await User.findOne({discordId});
          return user ? done(null, user): done(null, null);
      } catch (err) {
          console.log(err)
          done(err, null)
      }
  });
  
  passport.use(new DiscordStrategy({
      clientID: process.env.DASBOARD_CLIENT_ID,
      clientSecret: process.env.DASBOARD_CLIENT_SECRET,
      callbackUrl: process.env.DASBOARD_CALLBACK_URL,
      scope: ['identify','guilds'],
  }, async (accessToken, refreshToken, profile, done) =&gt; {
      const {id, username, discriminator, avatar, guilds} = profile;
      try{
          const findUser = await User.findOneAndUpdate(
              { discordId: id }, 
              {
              discordTag: `${username}#${discriminator}`,
              avatar,
              guilds,
          }, 
          {new: true});
          if ( findUser ) {
              console.log('++')
              return done(null, findUser);
          } else {
              const newUser = await User.create({
                  discordId: id,
                  discordTag: `${username}#${discriminator}`,
                  avatar,
                  guilds,
              })
              return done(null, newUser)
          }
      } catch(err){
          console.log(err);
          return done(err, null)
      }
  })
  );
  </code></pre>
  <p>++</p>
  <pre><code>Error: Failed to serialize user into session
      at pass (C:\Users\pilat\Desktop\makrel beta 2\backend\node_modules\passport\
  lib\authenticator.js:281:19)
      at serialized (C:\Users\pilat\Desktop\makrel beta 2\backend\node_modules\pas
  sport\lib\authenticator.js:286:7)
      at C:\Users\pilat\Desktop\makrel beta 2\backend\src\strategies\discord.js:6:
  5
      at pass (C:\Users\pilat\Desktop\makrel beta 2\backend\node_modules\passport\
  lib\authenticator.js:294:9)
      at Authenticator.serializeUser (C:\Users\pilat\Desktop\makrel beta 2\backend
  \node_modules\passport\lib\authenticator.js:299:5)
      at SessionManager.logIn (C:\Users\pilat\Desktop\makrel beta 2\backend\node_m
  odules\passport\lib\sessionmanager.js:14:8)
      at IncomingMessage.req.login.req.logIn (C:\Users\pilat\Desktop\makrel beta 2
  \backend\node_modules\passport\lib\http\request.js:50:33)
      at Strategy.strategy.success (C:\Users\pilat\Desktop\makrel beta 2\backend\n
  ode_modules\passport\lib\middleware\authenticate.js:253:13)
      at verified (C:\Users\pilat\Desktop\makrel beta 2\backend\node_modules\passp
  ort-oauth2\lib\strategy.js:186:20)
      at Strategy._verify (C:\Users\pilat\Desktop\makrel beta 2\backend\src\strate
  gies\discord.js:37:20)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
  </code></pre>
  <p>this is the error given to the console. What should ı do ?</p>