Skip to content

Commit

Permalink
Merge pull request #2107 from leedm777/fix-sessionless-websockets
Browse files Browse the repository at this point in the history
Fix crash when using sessionless requests over WebSockets.
  • Loading branch information
sgress454 committed Sep 26, 2014
2 parents 622e8a5 + 42bc9fd commit 9fe4e87
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/hooks/sockets/lib/interpreter/saveSessionAndThen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ module.exports = function saveSessionAndThen(req, sails, cb) {
return function saveSession () {
var ctx = this,
args = Array.prototype.slice.call(arguments);

req.session.save(function (err) {
var next = function (err) {
if (err) {
sails.log.error('Session could not be persisted:',err);
}
cb.apply(ctx,args);
});
};

// If we have a session on the request, save it
// Otherwise, process the callback on the next tick
if (req.session) {
req.session.save(next);
} else {
process.nextTick(next);
}
};
};

0 comments on commit 9fe4e87

Please sign in to comment.