Created
November 1, 2018 10:00
-
-
Save holyjak/bd5060bfb16cd1431f306761656b55d7 to your computer and use it in GitHub Desktop.
Async hooks on Nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const asyncHooks = require('async_hooks'); // Node 8.9+ | |
const querystring = require('querystring'); | |
const crypto = require("crypto"); | |
const context = {}; | |
function createHooks() { | |
function init(asyncId, type, triggerId, resource) { | |
// if (context[triggerId]) { | |
// context[asyncId] = context[triggerId]; | |
// } | |
} | |
function destroy(asyncId) { | |
// delete context[asyncId]; | |
} | |
const asyncHook = asyncHooks.createHook({ init, destroy }); | |
asyncHook.enable(); | |
} | |
createHooks() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment