jaredhanson / passport

Simple, unobtrusive authentication for Node.js.
https://www.passportjs.org?utm_source=github&utm_medium=referral&utm_campaign=passport&utm_content=about
MIT License
22.93k stars 1.24k forks source link

authenticate hangs in POST request on NodeJS v14 #797

Open michalhonc opened 3 years ago

michalhonc commented 3 years ago

authenticate function hangs in POST requests on NodeJS v14.x. When I downgrade to v12.x or when I call function inside GET request handler it works as it should.

I've only tried it with ExpressJS and local strategy. I also tried to pass callback function as a second argument but it still hangs.

// POST
router.post('/login', (req, res, next) => {
  passport.authenticate('local', { // hangs here in NodeJS v14.x
    successRedirect: '/dashboard',
    failureRedirect: '/login',
  })(req, res, next);
});

// GET
router.get('/', (req, res, next) => {
  passport.authenticate('local', { // works with GET request even in NodeJS v14.x
    successRedirect: '/dashboard',
    failureRedirect: '/login',
  })(req, res, next);
});

Environment

alexjv89 commented 3 years ago

similar problem here.

shanequint commented 2 years ago

Had the same issue. I was able to solve my issue by upgrading my pg dependency. It was hanging when it would query the postgres database to find the user and password hash via sequelize. Hope this helps.