Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 9 additions & 27 deletions test/addons/make-callback-recurse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,38 +132,20 @@ function checkDomains() {
}));
}), 1);

// Make sure nextTick, setImmediate and setTimeout can all recover properly
// after a thrown makeCallback call.
process.nextTick(common.mustCall(function() {
function testTimer(id) {
// Make sure nextTick, setImmediate and setTimeout can all recover properly
// after a thrown makeCallback call.
const d = domain.create();
d.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, 'throw from domain 3');
assert.strictEqual(e.message, `throw from domain ${id}`);
}));
makeCallback({domain: d}, function() {
throw new Error('throw from domain 3');
throw new Error(`throw from domain ${id}`);
});
throw new Error('UNREACHABLE');
}));
}

setImmediate(common.mustCall(function() {
const d = domain.create();
d.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, 'throw from domain 2');
}));
makeCallback({domain: d}, function() {
throw new Error('throw from domain 2');
});
throw new Error('UNREACHABLE');
}));

setTimeout(common.mustCall(function() {
const d = domain.create();
d.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, 'throw from domain 1');
}));
makeCallback({domain: d}, function() {
throw new Error('throw from domain 1');
});
throw new Error('UNREACHABLE');
}));
process.nextTick(common.mustCall(testTimer.bind(null, 3)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 3 of these functions allow passing arguments to the callback, why not take advantage of that instead of binding?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's late and I'm tired and not thinking as clearly as I should be.

Oh, wait, it's 8:41 PM. Can't use that excuse.

Anyway, yes, changed! Thanks.

setImmediate(common.mustCall(testTimer.bind(null, 2)));
setTimeout(common.mustCall(testTimer.bind(null, 1)), 1);
}