Time out for How to Use Passport Strategies test case

Hi there, I cannot pass the How to Use Passport Strategies 2nd case: A POST request to /login should correctly redirect to /. It always says time-out. Below is my code:

"use strict";

const express = require("express");
const bodyParser  = require('body-parser');
const fccTesting = require("./freeCodeCamp/fcctesting.js");
const passport = require("passport");
const session = require("express-session");
const ObjectID = require('mongodb').ObjectID;
const mongo = require('mongodb').MongoClient;
const LocalStrategy = require('passport-local');

const app = express();

app.set('view engine','pug');
fccTesting(app); //For FCC testing purposes
app.use("/public", express.static(process.cwd() + "/public"));
app.use(bodyParser.urlencoded({ extended: true }));

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,


mongo.connect(process.env.DATABASE, {useUnifiedTopology: true}, (err, client) => {
  var db = client.db("test");
  if(err) {
    console.log('Database error: ' + err);
  } else {
    console.log('Successful database connection');

    //serialization and app.listen
    passport.serializeUser((user, done) => {
      done(null, user._id);

    passport.deserializeUser((id, done) => {
        {_id: new ObjectID(id)},
          (err, doc) => {
            done(null, doc);

  passport.use(new LocalStrategy(
    function(username, password, done) {
      db.collection('users').findOne({ username: username }, function (err, user) {
        console.log('User '+ username +' attempted to log in.');
        if (err) { return done(err); }
        if (!user) { return done(null, false); }
        if (password !== user.password) { return done(null, false); }
        return done(null, user);

    app.route("/").get((req, res) => {
      //Change the response to render the Pug template
      //res.send(`Pug template is not defined.`);
      res.render(process.cwd() + '/views/pug/index', {title: 'Hello', message: 'Please login',showLogin: true});

    //app.route("/login").psot( passport.authenticate('local', { failureRedirect: '/login' }),
    //app.route('/login').post(passport.authenticate('local', { failureRedirect: '/' }), (req, res, next) => {
    app.route('/login').post((req,res) => {
      //User {USERNAME} attempted to log in
      console.log("User " + req.body.username + " attempted to log in");
          .get((req,res) => {
               res.render(process.cwd() + '/views/pug/profile');
    app.listen(process.env.PORT || 3000, () => {
      console.log("Listening on port " + process.env.PORT);

Even I copied the suggested answer from github https://gist.github.com/JosephLivengood/8a335d1a68ed9170da02bb9d8f5b71d5
it returned the same time out issue. My code is put on Repl.it. Any help would be highly appreciated. Thanks.

For those getting the same time out issue, I finally pass the test case by using Firefox instead of Chrome browser with the same code.

Just to mention this for others: The way Repli.it creates the Picture-In-Picture preview of the app, causes many issues with the use of cookies and the continuation of the session.

If you encounter related issues, opening the app preview in a new tab of its own could help.