From 9bc3004799e82cd9403a516c9531feb6561b2a69 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Thu, 8 Apr 2021 11:44:17 +0200 Subject: [PATCH] stargate: Make broadcastTx timeout check more specific --- packages/stargate/src/stargateclient.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/stargate/src/stargateclient.ts b/packages/stargate/src/stargateclient.ts index 3e1c2092..2891999a 100644 --- a/packages/stargate/src/stargateclient.ts +++ b/packages/stargate/src/stargateclient.ts @@ -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)),