Workflow signal and query

Hi, we are trying to adopt Temporal at our company but we have a fundamental issue regarding signals and queries.

One of our use cases is multi-step registration and this is the outline of the workflow:

  1. Receive HTTP request and begin execution of the workflow with some parameters like email/phone…
  2. The workflow executes validation code and then sends a verification code to the provided email/phone. If there is any error during this phase the workflow exits.
  3. Then it waits for signals, one signal that can be received is the verification code and another is a resend request that sends the verification code again. There is also a timer for timeout at which we stop the workflow.
  4. When it receives the verification code, it verifies it with our external provider and if it’s correct, creates a user record in the DB.

Now along of these steps there can be an error for example when the user sends a HTTP request for registration, we have to send him a response indicating either an error during validation or sending, or a success.
Another example is when the user sends a HTTP request with the code, we send a signal to the workflow and then we have to send him a response if the code is correct or not.

We tried accomplishing that with queries so after the code is sent we change a boolean variable to true and if there is an error we set a variable. In the HTTP request code, we execute the workflow and then query the workflow for results and because sending the code takes some time, the query already returns a result with variables set to false even though later the operation is successful.

One of the ways I guess is polling the query every x milliseconds but that is a lot of queries and latency and it doesn’t feel right to me.
Has anybody encountered this problem and has any solutions?

The solution is a synchronous update feature that is expected to be a part of the next release. Polling query every x milliseconds is a reasonable workaround until the update is released.