Skip to content

Commit

Permalink
Revert "Lazy-load CLS module"
Browse files Browse the repository at this point in the history
  • Loading branch information
josieusa authored and Emiliano Daddario committed Dec 9, 2016
1 parent 7cef481 commit 97873ae
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions server/current-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@

'use strict';

var cls = require('continuation-local-storage');
var domain = require('domain');

// Require CLS only when using the current context feature.
// As soon as this require is done, all the instrumentation/patching
// of async-listener is fired which is not ideal.
//
// Some users observed stack overflows due to promise instrumentation
// and other people have seen similar things:
// https://github.com/othiym23/async-listener/issues/57
// It all goes away when instrumentation is disabled.
var cls = function() {
return require('continuation-local-storage');
};

var LoopBackContext = module.exports;

/**
Expand Down Expand Up @@ -85,7 +74,7 @@ LoopBackContext.createContext = function(scopeName) {
process.context = process.context || {};
var ns = process.context[scopeName];
if (!ns) {
ns = cls().createNamespace(scopeName);
ns = cls.createNamespace(scopeName);
process.context[scopeName] = ns;
// Set up LoopBackContext.getCurrentContext()
LoopBackContext.getCurrentContext = function() {
Expand Down

0 comments on commit 97873ae

Please sign in to comment.