From 137073d2422ce1810bb533186cbbd4c9c47e6537 Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Wed, 18 Oct 2023 19:42:16 +1300 Subject: [PATCH] Fix ratelimit check (#78) * Fix ratelimit response check * Add changelog release scripts --- packages/common-algorand/package.json | 3 ++- packages/node/CHANGELOG.md | 2 ++ packages/node/package.json | 3 ++- packages/node/src/algorand/api.connection.ts | 5 ++++- packages/types/package.json | 3 ++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/common-algorand/package.json b/packages/common-algorand/package.json index 08f482e7..18128b9b 100644 --- a/packages/common-algorand/package.json +++ b/packages/common-algorand/package.json @@ -5,7 +5,8 @@ "scripts": { "build": "rm -rf dist && tsc -b", "test": "echo \"Error: no test specified\" && exit 1", - "format": "prettier --write \"src/**/*.ts\"" + "format": "prettier --write \"src/**/*.ts\"", + "changelog:release": "echo \"Updating changelog $npm_package_version\" && npx chan release $npm_package_version --git-url \"https://github.com/subquery/subql-algorand\" --release-prefix=\"common-algorand/\"" }, "homepage": "https://github.com/subquery/subql", "repository": "github:subquery/subql-algorand", diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index a8c4998c..b9fcd379 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- 429 rate limit error handling ## [3.0.1] - 2023-10-12 ### Changed diff --git a/packages/node/package.json b/packages/node/package.json index 8b4332a6..c545dd68 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -10,7 +10,8 @@ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev": "nodemon", - "start:prod": "node dist/main" + "start:prod": "node dist/main", + "changelog:release": "echo \"Updating changelog $npm_package_version\" && npx chan release $npm_package_version --git-url \"https://github.com/subquery/subql-algorand\" --release-prefix=\"node-algorand/\"" }, "homepage": "https://github.com/subquery/subql", "repository": "github:subquery/subql-algorand", diff --git a/packages/node/src/algorand/api.connection.ts b/packages/node/src/algorand/api.connection.ts index 932da986..eeee8442 100644 --- a/packages/node/src/algorand/api.connection.ts +++ b/packages/node/src/algorand/api.connection.ts @@ -69,7 +69,10 @@ export class AlgorandApiConnection formatted_error = AlgorandApiConnection.handleTimeoutError(e); } else if (e.message.startsWith(`disconnected from `)) { formatted_error = AlgorandApiConnection.handleDisconnectionError(e); - } else if (e.message.startsWith(`Rate Limited at endpoint`)) { + } else if ( + e.message.startsWith(`Rate Limited at endpoint`) || + (e as any).statusCode === 429 + ) { formatted_error = AlgorandApiConnection.handleRateLimitError(e); } else if (e.message.includes(`Exceeded max limit of`)) { formatted_error = AlgorandApiConnection.handleLargeResponseError(e); diff --git a/packages/types/package.json b/packages/types/package.json index 099fb6f3..79718f83 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -6,7 +6,8 @@ "repository": "github:subquery/subql-algorand", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "rm -rf dist && tsc -b" + "build": "rm -rf dist && tsc -b", + "changelog:release": "echo \"Updating changelog $npm_package_version\" && npx chan release $npm_package_version --git-url \"https://github.com/subquery/subql-algorand\" --release-prefix=\"types-algorand/\"" }, "author": "Ian He", "main": "dist/index.js",