diff options
author | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-08-17 11:30:16 +0000 |
---|---|---|
committer | Luca Matei Pintilie <lucafulger@gmail.com> | 2022-08-17 11:30:16 +0000 |
commit | 357b50eea4d323662ae20aa8c0577936b80d8398 (patch) | |
tree | c1b441368ad35c6c91ef114104c7e6c75a8c9360 | |
parent | 98b7f840be40dc696be0b1159e328e657e580977 (diff) | |
download | speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar.gz speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar.bz2 speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar.lz speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar.xz speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.tar.zst speedrunbot-slash-357b50eea4d323662ae20aa8c0577936b80d8398.zip |
Fix loop if the getAll functions reaches the limit and fix the posts test
Diffstat (limited to '')
-rwxr-xr-x | src/srcom/utils.ts | 11 | ||||
-rw-r--r-- | tests/srcom/posts.test.ts | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/srcom/utils.ts b/src/srcom/utils.ts index 77c57eb..3239633 100755 --- a/src/srcom/utils.ts +++ b/src/srcom/utils.ts @@ -110,6 +110,17 @@ export async function getAll<T>( attempts++; if (attempts > 5) break; await delay(30_000); + } else if (res.status === 400) { + const body = await res.json(); + // Above 10k speedrun.com just breaks + // With this error message + if (body.message === "Invalid pagination values.") break; + else { + // This is an unexpected error + // So try to walk it off + console.error(body); + break; + } } continue; } else attempts = 0; diff --git a/tests/srcom/posts.test.ts b/tests/srcom/posts.test.ts index aad5f10..788cd53 100644 --- a/tests/srcom/posts.test.ts +++ b/tests/srcom/posts.test.ts @@ -4,8 +4,8 @@ import { posts } from "../../src/srcom/posts.ts"; Deno.test("Get user posts by username", async () => { const res = await posts("1", { outputType: "plain" }); const expected = `Posts: 1 -Site Forums: 588 +Site Forums: 589 Game Forums: 779 -Total: 1367`; +Total: 1368`; assertEquals(res, expected); }); |