-
Notifications
You must be signed in to change notification settings - Fork 7.3k
timers: set{Immediate,Timeout} and general event loop clarification #5943
Comments
+1 This should go in doc/api/timers.markdown, I think. |
Maybe link to your explanation from the process.nextTick() documentation? On the subject of process.nextTick(), its documentation could be improved too: "It typically runs before any other I/O events fire, but there are some exceptions." - that's wrong, right? nextTick callbacks run after a callback into JS land, whether it's I/O related or not. |
@bnoordhuis correct. the |
@tjfontaine just going to voice this again. I don't think the change to run all function cb(arg) {
return function() {
console.log(arg);
process.nextTick(function() {
console.log('nextTick - ' + arg);
});
}
}
cb('0')();
setImmediate(cb('1'));
setImmediate(cb('2'));
// output:
// 0
// nextTick - 0
// 1
// 2
// nextTick - 1
// nextTick - 2 When instead the output should be: // output
// 0
// nextTick - 0
// 1
// nextTick - 1
// 2
// nextTick - 2 If people think IMO we should be checking |
FWIW, (EDIT: Trevor changed the example.) |
I've opened #5950 with some changes. Feel the wording here needs to be precise so looking for feedback while I write it out. |
@trevnorris ... assuming we can close this also since #5950 was closed. |
Add better documentation about the event loop so people can easily understand why things like the following occur:
@isaacs think this should go in the standard API docs, or some other location we can reference?
The text was updated successfully, but these errors were encountered: