In node.js why does passport session stop formidable from triggering 'file' events?
Asked Answered
E

2

8

In my app I am only using

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

and not

app.use(express.bodyParser());

so that I can manually parse file uploads. It seems that this line

app.use(passport.session());

stops formidable from triggering file events:

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

How can I use passport session and not clash with formidable file event?

Exurbia answered 23/1, 2013 at 12:6 Comment(0)
C
3

Looks like they've added a way to fix this. Using app.use(passport.session({pauseStream: true})); instead will prevent async deserializations from breaking some middleware.

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

Clownery answered 16/8, 2013 at 22:33 Comment(0)
A
0

The passport.session() method calls your passport.deserializeUser(), which itself usually makes a database call to fetch the user. This database call delays the execution of code that starts listening to the incoming data. That is, the data arrives while nobody is listening for it.

Abbotson answered 26/4, 2013 at 11:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.