From db50801a6f932e14efae81ffd8e98b60d69059a7 Mon Sep 17 00:00:00 2001 From: Eugene Shvets <3442792+chaosrealm@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:36:20 -0800 Subject: [PATCH] Fix `Indexer.run` API to correctly process HTTP status code (#52) * Fix Indexer.run to correctly process HTTP status code * Extend test hooks timeouts --- src/indexers/hosted/hosted-indexers.test.ts | 4 ++-- src/indexers/hosted/indexer.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/indexers/hosted/hosted-indexers.test.ts b/src/indexers/hosted/hosted-indexers.test.ts index f3a2849..3417a67 100644 --- a/src/indexers/hosted/hosted-indexers.test.ts +++ b/src/indexers/hosted/hosted-indexers.test.ts @@ -21,13 +21,13 @@ beforeEach(async () => { const catalogName = `catalog-${Date.now()}`; catalog = await testClient.configureCatalog(catalogName, config); -}, 20000); +}, 30000); afterEach(async () => { if (catalog) { await catalog.delete(); // this will also delete any indexer referencing this catalog } -}, 20000); +}, 30000); test("Test hosted indexer APIs", { timeout: 60000 }, async () => { const indexerName = `indexer-sdk-test-web-${Date.now()}`; diff --git a/src/indexers/hosted/indexer.ts b/src/indexers/hosted/indexer.ts index 690afbc..f39a64a 100644 --- a/src/indexers/hosted/indexer.ts +++ b/src/indexers/hosted/indexer.ts @@ -131,7 +131,8 @@ export class Indexer { async run(): Promise { const res = await this.apiClient.POST(`/indexers/${this.config.name}/run`); - if (res.status !== 200) { + // 200 is returned if the indexer was already running, 202 is returned if the indexer was started + if (res.status !== 202 && res.status !== 200) { const message = res.status === 400 ? await res.text() : res.statusText; throw new Error(`Failed to run indexer: ${message}`); }