On Mon, May 28, 2012 at 4:18 PM, lbdremy <remyloubra...@gmail.com> wrote: > Hey, > > I'm using node v0.6.16 and if I call the `abort` method of the instance of > `http.ClientRequest` returned by `http.get()`, I catch an error: `Error: > socket hang up`. > > For example with this code: > > ```js > var http = require('http'); > > var options = { > host : 'google.com' > } > var request = http.get(options,function(res){ > var body = ''; > res.on('error',function(err){ > console.error(err); > }); > > res.on('close',function(){ > console.log('response' closed); > }); > > res.on('end',function(){ > console.log('response ended'); > console.log(body); > }); > > res.on('data',function(chunk){ > body += chunk; > }); > }); > > request.on('error',function(err){ > console.log('v request error v') > console.error(err); > }); > > request.on('close',function(){ > console.log('request closed'); > }) > > setTimeout(function(){ > request.abort(); > console.log('request aborted'); > },100); > ``` > Output: > > ``` > request aborted > request closed > v request error v > { [Error: socket hang up] code: 'ECONNRESET' } > ``` > > Does this error is an expected behavior of node when calling abort on an > http request or something is wrong?
It's an expected error event. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en