Make submitAndAwait
errors immediately identifiable
#2108
Labels
good first issue
Good for newcomers
submitAndAwait
errors immediately identifiable
#2108
I've been trying to implement support for the
submitAndAwait
subscription but came across a problem related to invalid transactions. The current workflow of the TS SDK is as follows:submit
mutationBecause the
submit
endpoint is a mutation, its response is immediate - either it fails or succeeds in tx submission.When implementing
submitAndAwait
, I wanted to have behavior similar to the one described above:.next()
method which the user can call to await the subscription whenever they see fitThe problem I encountered is that I can't know if a transaction validity error happened until I read the response body of the subscription, but the response isn't necessarily immediate because the transaction might not have failed and is awaiting execution, in which case me trying to read the body would hang until the status update is streamed, which will block us from returning the iterator to the user.
The problem in code looks like this:
After pondering about it, two solutions came to mind:
statusChange
. This would immediately return aSubmittedStatus
response, which is great because we would then know that we'll get a response immediately from the node and can check if it's an error or not.I am more inclined to the second solution because the
SubmittedStatus
also contains the time of submission which may be of interest for some.The text was updated successfully, but these errors were encountered: