Joystream / joystream

Joystream Monorepo
http://www.joystream.org
GNU General Public License v3.0
1.42k stars 115 forks source link

Current Implementation of `sendExtrinsic` function may stuck indefinitely if the Tx has already finalised before processing the callback of `tx.signAndSend` #4802

Closed zeeshanakram3 closed 1 year ago

zeeshanakram3 commented 1 year ago

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 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.

zeeshanakram3 commented 1 year ago

Addressed in #4803