Skip to content

Commit

Permalink
fix(website): Handle 503 error from SILO
Browse files Browse the repository at this point in the history
See GenSpectrum/LAPIS-SILO#295
SILO throws an error now when it did not load a database yet.
  • Loading branch information
fengelniederhammer committed Feb 26, 2024
1 parent b2076f6 commit bd2848c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion website/src/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion website/tests/playwrightSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. ' +
Expand Down Expand Up @@ -98,6 +98,10 @@ async function checkLapisState(lapisClient: LapisClient): Promise<LapisStateBefo

const numberOfSequencesInLapisResult = await lapisClient.call('aggregated', {});

if (numberOfSequencesInLapisResult.isErr() && numberOfSequencesInLapisResult.error.status === 503) {
return LapisStateBeforeTests.NoSequencesInLapis;
}

if (numberOfSequencesInLapisResult._unsafeUnwrap().data[0].count === 0) {
return LapisStateBeforeTests.NoSequencesInLapis;
}
Expand Down

0 comments on commit bd2848c

Please sign in to comment.