Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.