In v0.10, this is quite different!

```javascript
// works on v0.10, not on v0.8
var http = require('http');

var server = http.createServer();

server.listen(8000);

server.on('request', function(req, res) {
  http.get("http://google.com/index.html";, function(response) {
    req.resume()
    response.pipe(res)
    req.on("end", function() {
      console.log("ENDED");
    });
  });
});
```

Because stream `'end'` doesn't happen until you consume the request,
it actually *hasn't* happened yet.

So, instead of missing the `'end'` like you would on v0.8, it's
*hanging* waiting for you to consume the stream, because it starts out
paused until you consume it.

On Tue, Apr 2, 2013 at 10:17 AM, Edgar Veiga <[email protected]> wrote:
> I'm working on node for about an year, and keep forgetting these basic
> stuff.
>
> Thanks, time indeed flies
>
>
> On Tuesday, 2 April 2013 18:11:17 UTC+1, Fedor Indutny wrote:
>>
>> Because time flies.
>>
>> Imagine that `req` ends after 1 second, but `http.get` invokes callback
>> only after 2 seconds. So where is your `end` event? You missed it.
>>
>> Cheers,
>> Fedor.
>>
>>
>> On Wed, Apr 3, 2013 at 12:03 AM, Edgar Veiga <[email protected]> wrote:
>>>
>>> Hello everyone,
>>>
>>> Maybe this is an already reported problem, either way, I couldn't find
>>> any topic on it!
>>>
>>> Why do I loose the end event if the listener is inside of a request?
>>>
>>> Example:
>>> https://gist.github.com/eveiga/5293995
>>>
>>> Best regards!
>>>
>>> --
>>> --
>>> 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 [email protected]
>>>
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
> --
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to