Created
November 23, 2017 16:41
-
-
Save guyguyon/3340a1ac45732c75eb6d19a528ec7d2c to your computer and use it in GitHub Desktop.
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 fs = require('fs'); | |
| const async_hooks = require('async_hooks'); | |
| async_hooks.createHook({ | |
| init(asyncId, type, triggerAsyncId) { | |
| fs.writeSync(1, `Init ${type} resource: asyncId: ${asyncId} trigger: ${triggerAsyncId}\n`); | |
| }, | |
| destroy(asyncId) { | |
| const eid = async_hooks.executionAsyncId(); | |
| fs.writeSync(1, `Destroy resource: execution: ${eid} asyncId: ${asyncId}\n`); | |
| } | |
| }).enable(); | |
| const eid = async_hooks.executionAsyncId(); | |
| fs.writeSync(1, `Calling setTimeout: execution: ${eid}\n`); | |
| setTimeout(() => { | |
| const eid = async_hooks.executionAsyncId(); | |
| fs.writeSync(1, `Inside setTimeout: execution: ${eid}\n`); | |
| }, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment