Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let executionScopeDepth = 0;
// Contains the call site objects of all active scopes
const traces = new Map();
//
// Mainiputlate stack trace
//
// add lastTrace to the callSite array
chain.filter.attach(function (error, frames) {
return frames.filter(function (callSite) {
const name = callSite && callSite.getFileName();
return (!name || (name !== 'async_hooks.js' && name !== 'internal/async_hooks.js'));
});
});
chain.extend.attach(function (error, frames) {
const lastTrace = traces.get(asyncHook.executionAsyncId());
frames.push.apply(frames, lastTrace);
return frames;
});
//
// Track handle objects
//
const hooks = asyncHook.createHook({
init: asyncInit,
before: asyncBefore,
after: asyncAfter,
destroy: asyncDestroy
});
hooks.enable();