Skip to content

Commit

Permalink
Use setImmediate when available, otherwise fallback to nextTick
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Patterson committed Feb 7, 2014
1 parent 54e6dfb commit 3eaed2f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion request.js
Expand Up @@ -453,7 +453,10 @@ Request.prototype.init = function (options) {
response_counter = 0;

function wait_for_socket_response(){
setImmediate(function(){
var detach;
if('undefined' == typeof setImmediate ) detach = process.nextTick
else detach = setImmediate;
detach(function(){
// counter to prevent infinite blocking waiting for an open socket to be found.
response_counter++;
var trying = false;
Expand Down

0 comments on commit 3eaed2f

Please sign in to comment.