@creditkarma/async-scope
Advanced tools
Comparing version 0.0.14 to 0.0.15
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const AsyncHooks = require("@creditkarma/async-hooks"); | ||
const logger = require("./logger"); | ||
const Utils = require("./utils"); | ||
@@ -21,10 +22,17 @@ const constants_1 = require("./constants"); | ||
init(asyncId, type, triggerAsyncId, resource) { | ||
self._ensureNode(triggerAsyncId); | ||
const parentNode = self.asyncMap[triggerAsyncId]; | ||
if (parentNode !== undefined) { | ||
parentNode.children.push(asyncId); | ||
parentNode.timestamp = Date.now(); | ||
self._addNode(asyncId, triggerAsyncId); | ||
const savedMap = self.asyncMap; | ||
try { | ||
self._ensureNode(triggerAsyncId); | ||
const parentNode = self.asyncMap[triggerAsyncId]; | ||
if (parentNode !== undefined) { | ||
parentNode.children.push(asyncId); | ||
parentNode.timestamp = Date.now(); | ||
self._addNode(asyncId, triggerAsyncId); | ||
} | ||
self._purge(); | ||
} | ||
self._purge(); | ||
catch (err) { | ||
logger.error(`An error occurred while creating scope: `, err); | ||
self.asyncMap = savedMap; | ||
} | ||
}, | ||
@@ -34,4 +42,11 @@ before(asyncId) { | ||
after(asyncId) { | ||
Utils.destroyNode(asyncId, self.asyncMap); | ||
self._purge(); | ||
const savedMap = self.asyncMap; | ||
try { | ||
Utils.destroyNode(asyncId, self.asyncMap); | ||
self._purge(); | ||
} | ||
catch (err) { | ||
logger.error(`An error occurred while destroying scope with id[${asyncId}]: `, err); | ||
self.asyncMap = savedMap; | ||
} | ||
}, | ||
@@ -38,0 +53,0 @@ promiseResolve(asyncId) { |
{ | ||
"name": "@creditkarma/async-scope", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "A thread local approximation built on async hooks, written in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/main/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42073
21
392
2