You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • It is asyncronous... http.get only calls the callback once the socket is open and it's received the header from the web server. If there's a failure then the connect handler won't be called.

    ... however there is no error handling at the moment. In node.js you'd do:

    http.get("http://www.google.com/index.ht­ml", function(res) {
      console.log("Got response: " + res.statusCode);
    }).on('error', function(e) {
      console.log("Got error: " + e.message);
    });
    

    and we don't do anything like that yet. The code will upload, but the error handler will never get called.

    ... to be honest I'm not sure it's that high priority, as you can work around it with:

    var err = setTimeout(function() {
      err = undefined;
      console.log("Oh No!");
    }, 60*6000);
    http.get("http://www.google.com/index.ht­ml", function(res) {
      if (err) clearTimeout(err);
      console.log("Got response: " + res.statusCode);
    });
    

    Basically if something stalled, the socket would have timed out after 60 seconds anyway and closed.

  • I'm not sure, how is this workaround working. The setTimeout runs timeout, but the http.get need to be wayted, while it calls the callback. But if we are there, then something is happend, whay it is called the callback, and if the callback called after 10 minutes, it will wait 10 minutes.
    And I cannot se, where this errTimeout kill the original http call/socket, if timed out.

About

Avatar for Gordon @Gordon started