Let’s say I have this simple code that responds with a .XML file.
app.post '/incoming', (req,res) ->
console.log "Hello, incoming call!"
message = req.body.Body
from = req.body.From
sys.log "From: " + from + ", Message: " + message
test = "hello"
r = new Twiml.Response()
r.append(new Twiml.Say('Hello, there!' + test + ' Enter your ATM card PIN'))
console.log(r.toString())
res.send r.toString()
Is it possible that if 2 requests come at the same time, one gets the wrong response? I’m asking this because I don’t fully understand how async works and if this is doing what I want it to do.
Thanks
If you want to know which client the response goes to, remove all code from the body apart from code that interacts with
reslike so :Now you can see that your sending
r.toString()to the correct response.Even if 2 requests come at the same time, javascript is single threaded and blocking so there are never any race conditions.