Skip to content

Instantly share code, notes, and snippets.

@holyjak
Created November 1, 2018 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holyjak/bd5060bfb16cd1431f306761656b55d7 to your computer and use it in GitHub Desktop.
Save holyjak/bd5060bfb16cd1431f306761656b55d7 to your computer and use it in GitHub Desktop.
Async hooks on Nodejs
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