In node.js, why does the passport session end due to the triggering of file events?

In my application I use

app.use(express.json()); app.use(express.urlencoded()); 

but not

 app.use(express.bodyParser()); 

so that I can manually parse the file upload. This line seems to be

 app.use(passport.session()); 

ceases to be formidable when triggering file events:

 form.on('file', function(name, file) { //never called }); 

How can I use a passport session and not face a formidable file event?

+7
source share
2 answers

Looks like they added a way to fix this. Using app.use(passport.session({pauseStream: true})); instead, it will prevent asynchronous deserialization due to a violation of some middleware.

Source: https://github.com/jaredhanson/passport/pull/106

+3
source

The passport.session() method calls your passport.deserializeUser() , which itself usually calls the database call to retrieve the user. This database call delays the execution of code that begins to listen for incoming data. That is, the data arrives while no one is listening.

0
source

All Articles