()
| 4 | let config; |
| 5 | |
| 6 | function lazyHookCreation() { |
| 7 | const inspector = internalBinding('inspector'); |
| 8 | const { createHook } = require('async_hooks'); |
| 9 | config = internalBinding('config'); |
| 10 | |
| 11 | hook = createHook({ |
| 12 | init(asyncId, type, triggerAsyncId, resource) { |
| 13 | // It's difficult to tell which tasks will be recurring and which won't, |
| 14 | // therefore we mark all tasks as recurring. Based on the discussion |
| 15 | // in https://github.com/nodejs/node/pull/13870#discussion_r124515293, |
| 16 | // this should be fine as long as we call asyncTaskCanceled() too. |
| 17 | const recurring = true; |
| 18 | inspector.asyncTaskScheduled(type, asyncId, recurring); |
| 19 | }, |
| 20 | |
| 21 | before(asyncId) { |
| 22 | inspector.asyncTaskStarted(asyncId); |
| 23 | }, |
| 24 | |
| 25 | after(asyncId) { |
| 26 | inspector.asyncTaskFinished(asyncId); |
| 27 | }, |
| 28 | |
| 29 | destroy(asyncId) { |
| 30 | inspector.asyncTaskCanceled(asyncId); |
| 31 | }, |
| 32 | trackPromises: false, |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | function enable() { |
| 37 | if (hook === undefined) lazyHookCreation(); |
no test coverage detected
searching dependent graphs…