Current Implementation of `sendExtrinsic` function may stuck indefinitely if the Tx has already finalised before processing the callback of `tx.signAndSend` #4802
Currently, the sendExtrinsic function (which is a wrapper around PolkadotJS' tx.signAndSend function) in Argus, Colossus & CLI may stuck indefinitely if the transaction has already finalized before processing the callback of tx.signAndSend.
This is because the if-condition in the sendExtrinsic function, would only resolve or reject if the transaction status is isInBlock or errored respectively. However, there might be the case that the transaction has already been finalized when the callback was run, so in that case, the promise would not resolve/reject. The function would be stuck and the calling function would be indefinitely waiting for the response.
Background
I discovered this issue in YT-synch (since it uses the exact implementation from monorepo), where occasionally the video creation service would get stuck, this mostly happened when the YT-synch would be doing intensive IO-bound work. So my hunch is that in such cases callback function would be scheduled to run after the Tx has been finalized.
Issue
Currently, the sendExtrinsic function (which is a wrapper around PolkadotJS'
tx.signAndSend
function) in Argus, Colossus & CLI may stuck indefinitely if the transaction has already finalized before processing the callback oftx.signAndSend
.This is because the if-condition in the
sendExtrinsic
function, would only resolve or reject if the transaction status isisInBlock
or errored respectively. However, there might be the case that the transaction has already been finalized when the callback was run, so in that case, the promise would not resolve/reject. The function would be stuck and the calling function would be indefinitely waiting for the response.Background
I discovered this issue in YT-synch (since it uses the exact implementation from monorepo), where occasionally the video creation service would get stuck, this mostly happened when the YT-synch would be doing intensive IO-bound work. So my hunch is that in such cases callback function would be scheduled to run after the Tx has been finalized.