Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

req and res should be bound inside the new context #8

Open
coltrane opened this issue Aug 25, 2015 · 1 comment
Open

req and res should be bound inside the new context #8

coltrane opened this issue Aug 25, 2015 · 1 comment

Comments

@coltrane
Copy link

The existing code binds req and res before starting a new context:

module.exports = function clsify(ns) {
  if (!ns) throw new Error('CLS namespace required');

  return function (req, res, next) {
    ns.bindEmitter(req);
    ns.bindEmitter(res);

    ns.run(function () {
      next();
    });
  };
};

But it seems that these should be bound within the new context. Something like this...

module.exports = function clsify(ns) {
  if (!ns) throw new Error('CLS namespace required');

  return function (req, res, next) {
    ns.run(function () {
      ns.bindEmitter(req);
      ns.bindEmitter(res);
      next();
    });
  };
};
@marcelboettcher
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants