From bd2848c78ab3eada7cac52546b0576f51179b86b Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Mon, 26 Feb 2024 15:11:30 +0100 Subject: [PATCH] fix(website): Handle 503 error from SILO See https://github.com/GenSpectrum/LAPIS-SILO/issues/295 SILO throws an error now when it did not load a database yet. --- website/src/utils/search.ts | 5 ++++- website/tests/playwrightSetup.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/website/src/utils/search.ts b/website/src/utils/search.ts index 193812584..93f220fb6 100644 --- a/website/src/utils/search.ts +++ b/website/src/utils/search.ts @@ -7,6 +7,7 @@ import type { ProblemDetail } from '../types/backend.ts'; import type { MetadataFilter, MutationFilter } from '../types/config.ts'; import { type LapisBaseRequest, type OrderBy, type OrderByType, orderByType } from '../types/lapis.ts'; import type { ReferenceGenomesSequenceNames } from '../types/referencesGenomes.ts'; + export type SearchResponse = { data: TableSequenceData[]; totalCount: number; @@ -46,7 +47,9 @@ export const getData = async ( const aggregateResult = await lapisClient.call('aggregated', searchFilters); - if (aggregateResult.isOk() && aggregateResult.value.data[0].count === 0) { + const siloDoesNotHaveDataYet = aggregateResult.isErr() && aggregateResult.error.status === 503; + const siloIsEmpty = aggregateResult.isOk() && aggregateResult.value.data[0].count === 0; + if (siloDoesNotHaveDataYet || siloIsEmpty) { return ok({ data: [], totalCount: 0, diff --git a/website/tests/playwrightSetup.ts b/website/tests/playwrightSetup.ts index 2478a8120..9005961ac 100644 --- a/website/tests/playwrightSetup.ts +++ b/website/tests/playwrightSetup.ts @@ -24,7 +24,7 @@ enum LapisStateBeforeTests { export default async function globalSetupForPlaywright() { const secondsToWait = 10; - const maxNumberOfRetries = 12; + const maxNumberOfRetries = 24; e2eLogger.info( 'Setting up E2E tests. In order to test search results, data will be prepared in LAPIS. ' + @@ -98,6 +98,10 @@ async function checkLapisState(lapisClient: LapisClient): Promise