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

Function tick1

test/async-hooks/test-embedder.api.async-resource.js:65–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63tick(1, common.mustCall(tick1));
64
65function tick1() {
66 checkInvocations(alcazares, { init: 1, before: 2, after: 2, destroy: 1 },
67 'alcazares emitted destroy');
68
69 // The below shows that we can pass any number as a trigger id
70 const pobTriggerId = 111;
71 const pobEvent = new AsyncResource('poblado', pobTriggerId);
72 const pobladoActivities = hooks.activitiesOfTypes([ 'poblado' ]);
73 const poblado = pobladoActivities[0];
74 assert.strictEqual(poblado.type, 'poblado');
75 assert.strictEqual(typeof poblado.uid, 'number');
76 assert.strictEqual(poblado.triggerAsyncId, pobTriggerId);
77 checkInvocations(poblado, { init: 1 }, 'poblado constructed');
78 pobEvent.runInAsyncScope(() => {
79 checkInvocations(poblado, { init: 1, before: 1 },
80 'poblado emitted before');
81 });
82
83 checkInvocations(poblado, { init: 1, before: 1, after: 1 },
84 'poblado emitted after');
85
86 // After we disable the hooks we shouldn't receive any events anymore
87 hooks.disable();
88 alcaEvent.emitDestroy();
89 tick(1, common.mustCall(tick2));
90
91 function tick2() {
92 checkInvocations(
93 alcazares, { init: 1, before: 2, after: 2, destroy: 1 },
94 'alcazares emitted destroy a second time after hooks disabled');
95 pobEvent.emitDestroy();
96 tick(1, common.mustCall(tick3));
97 }
98
99 function tick3() {
100 checkInvocations(poblado, { init: 1, before: 1, after: 1 },
101 'poblado emitted destroy after hooks disabled');
102 }
103}

Callers

nothing calls this directly

Calls 5

runInAsyncScopeMethod · 0.95
activitiesOfTypesMethod · 0.80
tickFunction · 0.50
disableMethod · 0.45
emitDestroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…