stargate: Make broadcastTx timeout check more specific

This commit is contained in:
willclarktech 2021-04-08 11:44:17 +02:00
parent ed077b9c15
commit 9bc3004799
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7

View File

@ -314,17 +314,19 @@ export class StargateClient {
.catch((error) => {
try {
const errorJson = JSON.parse(error.message);
if (errorJson.code !== -32603) {
// irrelevant error
throw error;
if (
// -32603 is "Internal Error"
// https://github.com/tendermint/tendermint/blob/v0.34.0/rpc/jsonrpc/types/types.go#L236
errorJson.code === -32603 &&
/timed out waiting for tx to be included in a block/i.test(errorJson.data)
) {
// now we poll to artificially extend the timeout
return handlePrematureTimeout();
}
} catch {
// invalid JSON
throw error;
}
// timed out waiting for tx to be included in a block
// now we poll to artificially extend the timeout
return handlePrematureTimeout();
throw error;
})
.then(resolve, reject)
.finally(() => clearTimeout(txPollTimeout)),