nestjs-cls
Version:
A continuation-local storage module compatible with NestJS's dependency injection.
13 lines (12 loc) • 634 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.globalClsService = void 0;
const async_hooks_1 = require("async_hooks");
const cls_service_1 = require("./cls.service");
const als = new async_hooks_1.AsyncLocalStorage();
// Establish a root ALS context so that subsequent enterWith() calls in guards
// scope to the current request's async context rather than the global root.
// This mitigates the enterWith() context-leak bug on Node.js < 24
// (fixed upstream in https://github.com/nodejs/node/pull/58029).
als.enterWith(undefined);
exports.globalClsService = new cls_service_1.ClsService(als);