Skip to content

Commit

Permalink
Fix Indexer.run API to correctly process HTTP status code (#52)
Browse files Browse the repository at this point in the history
* Fix Indexer.run to correctly process HTTP status code

* Extend test hooks timeouts
  • Loading branch information
chaosrealm authored Nov 4, 2024
1 parent 99922ee commit db50801
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/indexers/hosted/hosted-indexers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down
3 changes: 2 additions & 1 deletion src/indexers/hosted/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export class Indexer {

async run(): Promise<void> {
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}`);
}
Expand Down

0 comments on commit db50801

Please sign in to comment.