Need to call res.end() in Express 3.x?

2,430 views
Skip to first unread message

Tom

unread,
Nov 6, 2012, 2:50:21 AM11/6/12
to Express
In Express 2 the guide clearly stated that every single request should always be ended using `res.end`.

Now I notice that res.end is not in the API documentation, and that it is not mentioned anywhere.

It is however part of the node http server Response object, which Express inherits from.

Therefore my question is if I still need to call res.end for each request?

Tom

greelgorke

unread,
Nov 6, 2012, 4:16:00 AM11/6/12
to expre...@googlegroups.com
since response is realy extended http.ServerResponse this is valid: http://nodejs.org/docs/latest/api/http.html#http_response_end_data_encoding

there is a word MUST in it :)

tjholowaychuk

unread,
Nov 6, 2012, 11:27:48 AM11/6/12
to Express
res.end is a node thing, and it's lower level. usually you'd use
res.send(obj) or res.send('some string'), not res.end() it
does much less

tjholowaychuk

unread,
Nov 6, 2012, 11:28:06 AM11/6/12
to Express
http://expressjs.com/api.html#res.send

On Nov 5, 11:50 pm, Tom <tommed...@gmail.com> wrote:

Tom

unread,
Nov 6, 2012, 11:32:09 AM11/6/12
to expre...@googlegroups.com
Greetings TJ,

The docs do not mention whether one still has to execute `res.end` after `res.send` though.

After looking at the source this does not seem to be needed, as res.send appears to call res.end.

Thank you.

Tom

Op dinsdag 6 november 2012 23:28:09 UTC+7 schreef tjholowaychuk het volgende:

Anastasis Andronidis

unread,
Jun 4, 2014, 7:48:32 AM6/4/14
to expre...@googlegroups.com, tomm...@gmail.com
hello I am a new user, and I use Express 4. I believe that the .end() method is still NOT needed after .send().

I would like to see it documented on the official api though :)

Thanks

q2dg2b

unread,
Jan 18, 2015, 11:34:07 AM1/18/15
to expre...@googlegroups.com, tomm...@gmail.com
+1
Reply all
Reply to author
Forward
0 new messages