Sir..
promises is a good choice . i used step as it was the easiest to work
with .....
much regards
Faysal Banna
Meteorological Services
Rafic Harriri International Airport
Beirut - Lebanon
Mob: +961-3-258043
On 09/23/2013 03:35 PM, Eric Chaves wrote:
Hi guys,
Thanks all for the answers. I still digging into this problem but I
believe I found the problem. The method in question is used to perform
statistics and manage log regarding the client request. The client
answer is independent from this task, so we try to reply it's HTTP
request as soon as possible for better UI/UX experience on client
side, and than manage the rest of the task.
The code is fairly complex due to several calls to database and log
managers, creating a hell of callbacks. We use a middleware framework
(a kind of express) and my guess is that when I call "res next" in the
middleware it ends the current thread even with some callbacks pending.
We are trying to move this post-reply tasks into an emitter object and
handle this whit events + process.nexttick. What do you think?
*@pedro* due to the code complexity is not viable for me to post it here.
*@faysal* thanks for the code. We plan to use promises on our code but
haven't found the time yet to do it. I'm sure it will solve several
needs we have today.
*@greelgorke* as a troubleshooting exercise we did something similar
to your suggestion and the problem went away. However we can't keep
the client awaiting, this could lead us into other business problems.
Cheers,
Eric
--
Eric Chaves
(11) 98139-9880
2013/9/23 greelgorke <[email protected] <mailto:[email protected]>>
don't use res.send for that. use res.writeHead, perform yur
calcuation and request to the external server, receive the
response from it, do your stuf with it and res.write/res.end to
your client then
Am Freitag, 20. September 2013 22:20:49 UTC+2 schrieb Eric:
Hi guys,
I'm trying to write a service that performs the following actions:
1) receive an HTTP request from client with some data payload
in body.
2) immediately reply with HTTP response 200 - ok
3) perform some calculations based on the payload and than
performs an HTTP request to an external HTTP server.
To do that once my http callback is fired I call res.send()
and than I perform the calculations, then I create a new http
object (var http = require('http')) and call it's request
method. At this point the callback for this last call is never
triggered.
How should I do to reply to my http client as soon as possible
and than do another http request?
Thanks in advance,
Eric
--
--
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]
<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]
<mailto:nodejs%[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 a topic in
the Google Groups "nodejs" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/nodejs/gv0Wiq1ULp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to [email protected]
<mailto:nodejs%[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.