Skip to content

Context doesn't work with Node 4.3.1 #2094

Description

@kussberg

Hello,

we wanted to update our servers to Node v4.3.1 but unfortunately we have a problem with loopback context. We are using session manager for express and init the session when setContext is run:

// Configure to set current customer or employee app.use(function setContext(req, res, next) { var loopbackContext = loopback.getCurrentContext(); var session = req.session; session.sessionID = req.sessionID; loopbackContext.set('session', session); if (req.accessToken) { async.parallel({ customer: function (cb) { app.models.Customer.findById(req.accessToken.userId, function (err, customer) { cb(null, customer); }); }, employee: function (cb) { app.models.Employee.findById(req.accessToken.userId, function (err, employee) { cb(null, employee); }); } }, function (err, results) { if (loopbackContext) { if (results.customer) loopbackContext.set('customer', results.customer); if (results.employee) loopbackContext.set('employee', results.employee); } next(); }); } else { next(); } }); 

Inside of this function the loopbackContext.get('session') works without problem. The problem is, that when we use the context in a remote method, it doesn't work, as loopbackContext.get('session') - undefined:

var ctx = loopback.getCurrentContext();
var session = ctx && ctx.get('session'); <===== undefined

Any clues?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions