title: can a node express request be saved to memory? or other way to suspend a request and wait for another request
body: <p>we are using express in our node app that wrap a web-service to send text message by our service provider with the following flow:</p>
  
  <p>A client app (web-apps or other node apps) request to send a text message with the phone number and message body as parameters.</p>
  
  <p>Our node app will forward the request to our text message service provider, to the client’s parameters we add a uuid we generate before sending the request.</p>
  
  <p>The service provider will then reply to our request with either a successful message acceptance or any other kind of error that might have happened (wrong phone number, empty msg, etc...).</p>
  
  <p>We can now return to the client with the request status, success or failure (with a reason) to handle.</p>
  
  <p>All the above works great, here is the interesting part.</p>
  
  <p>Since the response from our request to the service provider only indicate the request accepted we will eventually get another request to our app from the service provider (POST request) this time if the message has actually been sent or not. This will also hold the uuid we gave the request so we could address the right message. This will arrive 5-10 seconds after the first response to our request.</p>
  
  <p>Now, we want to allow the client’s app to ask us if the message actually got sent or not. 
  So once they receives our first response to them that the message accepted, we return the uuid with that response as well, they can now send another request with that uuid to ask us for its status.</p>
  
  <p>In case we got the service provider notification we figured to cache that notification in memory using the uuid as the key. That way when the client requests arrives we will cache.get the status and response with that.</p>
  
  <p>The problem is that in most cases the client will ask to verify before the service provider sends his notification, meaning that when the client request arrives we still haven't got the status from the service provider.</p>
  
  <p>The way I see it there are 2 options to address this issue:</p>
  
  <ol>
  <li><p>By finding a way to save the request from the client (not sure if possible, memory?) until the POST request from the text message service provider arrive and pull it out if the ref id match, then return the response to the client.</p></li>
  <li><p>Once the client request to validate enters the route, call a function that will return a new promise. this will resolve only when the POST request arrives, it will probably need to iterate every couple of seconds or so and check if that POST with same ref id exists, and only then resolve the promise and that in turn return the response to the client. This could have a timeout of a minute or two so the client’s request won’t just timed-out.</p></li>
  </ol>
  
  <p>We have searched for days but haven’t found any similar use case or a solution.</p>
  
  <p>I’m well aware we can do that with sockets, but this feels too much, we would like to keep this app plain and simple.</p>
  
  <p>Appreciate your answers.
  Thanks.</p>