Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:45:07+00:00 2026-06-12T16:45:07+00:00

There is very strange behavior in Express, can’t figure out, mind cracking problem. So

  • 0

There is very strange behavior in Express, can’t figure out, mind cracking problem.

So suppose in req.user I have user id and here is my middleware code.

app.use(function(req, res, next){
  var User = mongoose.model('User');
  User.findById(req.user, function(err, user){
    if(err) return next(err);
    res.locals.user = user;
    console.log(user);
    next(); 
  });
}

So it is working just fine when request type is GET, but if request is POST it just get to infinite waiting, until I receive No data received.

There is no issues with database nor with session: console.log(user) always works.

This is very very strange… I even tried to use another async function and it didn’t work again for POST only requests.

fs.stat(__dirname + '/schemas/user.js', function(err, stat){
  next();
})

My conclusion is that if next() is being called from callback during POST request it just hangs, but who can explain me WHY???

The original issue that brings me here was when I was trying to use passport.js deserializer which reads user from mongodb for every request, so that fails too for POST only requests.

configurations

{
  "name": "myApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "./node_modules/.bin/nodemon app.js"
  },
  "dependencies": {
    "express": "3.0.0rc5", //did also tried with rc4
    "ejs": ">= 0.8.3",
    "express-partials": "latest",
    "mongodb": ">= 1.1.7",
    "mongoose": "*",
    "node-uuid": "*",
    "passport": "*",
    "passport-local": "*",
    "flashify": "*",
    "nodemon": "latest"
  }
}

express configuration

var app = express();
app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.logger('dev'));
  app.use(partials());
  app.use(express.cookieParser('Secret secret'));
  app.use(express.session());
  app.use(passport.initialize());
  app.use(passport.session());

  app.use(MY_MIDDLEWARE_HERE);

  app.use(express.favicon());  
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(flashify);
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});


app.configure('development', function(){
  app.use(express.errorHandler());
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:45:08+00:00Added an answer on June 12, 2026 at 4:45 pm

    I’m not sure this will have an effect, but its recommended to use bodyParser middleware earlier in the middleware stack. I would put it below cookieParser and above passport middleware, since many authentication mechanisms need to find parameters in the body.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a very strange problem with jQTransform and jQery 1.4.2. When I use
I found out really strange behavior on relatively simple use case, probably I can't
Very strange behavior, there is a round dot in the center of the screen
I'm having a very strange behavior in my game application. There are two classes
There is very little code out there that is in VB, and i'm getting
I'm getting so very strange behavior in my Objective C library (for iPhone). What
I'm getting a very strange behavior in MySQL, which looks like some kind of
Here is a very strange behavior using EJB beans: @Local public interface Provider {
My C# program has a very strange behavior. I'm using four ''hacky'' pinvoke methods
I have a very strange problem,I don't know whether it is awkward to normal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.