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

Function checkDomains

test/node-api/test_make_callback_recurse/test.js:95–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93
94
95function checkDomains() {
96 // Check that domains are properly entered/exited when called in multiple
97 // levels from both node::MakeCallback() and AsyncWrap::MakeCallback
98 setImmediate(common.mustCall(function() {
99 const d1 = domain.create();
100 const d2 = domain.create();
101 const d3 = domain.create();
102
103 makeCallback({ domain: d1 }, common.mustCall(function() {
104 assert.strictEqual(d1, process.domain);
105 makeCallback({ domain: d2 }, common.mustCall(function() {
106 assert.strictEqual(d2, process.domain);
107 makeCallback({ domain: d3 }, common.mustCall(function() {
108 assert.strictEqual(d3, process.domain);
109 }));
110 assert.strictEqual(d2, process.domain);
111 }));
112 assert.strictEqual(d1, process.domain);
113 }));
114 }));
115
116 setTimeout(common.mustCall(function() {
117 const d1 = domain.create();
118 const d2 = domain.create();
119 const d3 = domain.create();
120
121 makeCallback({ domain: d1 }, common.mustCall(function() {
122 assert.strictEqual(d1, process.domain);
123 makeCallback({ domain: d2 }, common.mustCall(function() {
124 assert.strictEqual(d2, process.domain);
125 makeCallback({ domain: d3 }, common.mustCall(function() {
126 assert.strictEqual(d3, process.domain);
127 }));
128 assert.strictEqual(d2, process.domain);
129 }));
130 assert.strictEqual(d1, process.domain);
131 }));
132 }), 1);
133
134 function testTimer(id) {
135 // Make sure nextTick, setImmediate and setTimeout can all recover properly
136 // after a thrown makeCallback call.
137 const d = domain.create();
138 d.on('error', common.mustCall(function(e) {
139 assert.strictEqual(e.message, `throw from domain ${id}`);
140 }));
141 makeCallback({ domain: d }, function() {
142 throw new Error(`throw from domain ${id}`);
143 });
144 throw new Error('UNREACHABLE');
145 }
146
147 process.nextTick(common.mustCall(testTimer), 3);
148 setImmediate(common.mustCall(testTimer), 2);
149 setTimeout(common.mustCall(testTimer), 1, 1);
150}

Callers

nothing calls this directly

Calls 4

setImmediateFunction · 0.50
makeCallbackFunction · 0.50
setTimeoutFunction · 0.50
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…