MCPcopy Index your code
hub / github.com/nodejs/node / lazyHookCreation

Function lazyHookCreation

lib/internal/inspector_async_hook.js:6–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4let config;
5
6function 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
36function enable() {
37 if (hook === undefined) lazyHookCreation();

Callers 2

enableFunction · 0.85
disableFunction · 0.85

Calls 2

createHookFunction · 0.70
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…