You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added a sample code below. If you run this express application, and open two browsers at the same time (getting 2 different sessions), and start running concurrent requests, you will see that all requests will receive the same response.locals object (see express/middleware.js). That causes concurrent requests to simply have this weird behavior of having its locals modified by another request, if they do async operations and have to wait.
Notice that I am not even creating a Cluster, I just required the module.
I didnt analyse much Cluster 2 code to see what happens during the require of the module, I just thought I should let you guys know about this strange behavior.
The text was updated successfully, but these errors were encountered:
I added a sample code below. If you run this express application, and open two browsers at the same time (getting 2 different sessions), and start running concurrent requests, you will see that all requests will receive the same response.locals object (see express/middleware.js). That causes concurrent requests to simply have this weird behavior of having its locals modified by another request, if they do async operations and have to wait.
Notice that I am not even creating a Cluster, I just required the module.
[email protected].*
[email protected]
var Cluster, app, express;
express = require('express');
Cluster = require('cluster2');
app = express();
app.port = process.env.PORT || process.env.VMC_APP_PORT || 3000;
app.configure(function() {
app.use(express.compress());
app.use(express.cookieParser('some secret'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({
secret: 'some secret'
}));
app.use(express.csrf());
app.use(function(req, res, next) {
res.locals.csrf = req.session._csrf;
res.locals.userAgent = req.headers['user-agent'];
return next();
});
app.use(app.router);
app.get('/', function(req, res) {
return setTimeout((function() {
if (req.session._csrf !== res.locals.csrf) {
console.log('ERROR, CSRF DOESNT MATCH');
}
return res.json('index');
}), Math.random() * 5000);
});
return module.exports = app;
});
I didnt analyse much Cluster 2 code to see what happens during the require of the module, I just thought I should let you guys know about this strange behavior.
The text was updated successfully, but these errors were encountered: