Created
September 1, 2017 13:56
-
-
Save tonylukasavage/a6d0c0c4258a52dbded1fd0131401207 to your computer and use it in GitHub Desktop.
basic async_hooks test
This file contains hidden or 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 async_hooks = require('async_hooks'), | |
fs = require('fs'), | |
http = require('http'); | |
const hook = async_hooks.createHook({ | |
init(asyncId, type, triggerAsyncId, resource) { | |
fs.writeSync(1, `[init] (${asyncId}:${triggerAsyncId}) ${type} - ${resource}\n`); | |
}, | |
before(asyncId) { | |
fs.writeSync(1, `[before] (${asyncId})\n`); | |
}, | |
after(asyncId) { | |
fs.writeSync(1, `[after] (${asyncId})\n`); | |
}, | |
destroy(asyncId) { | |
fs.writeSync(1, `[destroy] (${asyncId})\n`); | |
} | |
}).enable(); | |
http.createServer((req, res) => res.end()).listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment