helius-labs / helius-sdk

123 stars 39 forks source link

fix(txts): `sendSmartTransaction` Times Out But Transaction Is Confirmed #103

Closed tavindev closed 2 months ago

tavindev commented 2 months ago

Fixes #102 by throwing timeout error only if the current block height is greater than the lastValidBlockHeight returned by getLatestBlockhash used when creating the transaction.

tavindev commented 2 months ago

Thanks for the follow up!

Good point. We could use while (Date.now() - startTime < timeout || (await this.connection.getBlockHeight()) <= lastValidBlockHeight) instead, which would then only check the blockhash after the timeout. Considering that a transaction times out after ~60-90s, getBlockHeight would be called at most ~2 times. This way, only transactions near expiry time would have extra RPC calls. What do you think?

0xIchigo commented 2 months ago

No worries @tavindev! Yeah, that OR condition would work a lot better since we still have the initial timeout. I'm all for it

tavindev commented 2 months ago

Done!