Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit ab886be

Browse files
committed
Attach tick callbacks to active domain
1 parent a914bd0 commit ab886be

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/node.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,13 @@
235235
nextTickQueue = [];
236236

237237
try {
238-
for (var i = 0; i < l; i++) q[i]();
238+
for (var i = 0; i < l; i++) {
239+
var tock = q[i];
240+
var callback = tock.callback;
241+
if (tock.domain) tock.domain.enter();
242+
callback();
243+
if (tock.domain) tock.domain.exit();
244+
}
239245
}
240246
catch (e) {
241247
if (i + 1 < l) {
@@ -249,7 +255,9 @@
249255
};
250256

251257
process.nextTick = function(callback) {
252-
nextTickQueue.push(callback);
258+
var tock = { callback: callback };
259+
if (process.domain) tock.domain = process.domain;
260+
nextTickQueue.push(tock);
253261
process._needTickCallback();
254262
};
255263
};

0 commit comments

Comments
 (0)