Skip to content

Commit

Permalink
Cleanup + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanjunath committed Jan 12, 2025
1 parent 9e09ca6 commit ad5ad55
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 148 deletions.
9 changes: 7 additions & 2 deletions src/service-worker/src/armada/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {MsgAny} from '../msg';
import {sha1Binary} from '../sha1';

import {ContentAPIClient} from './api';
import {SwContentNodesFetchFailureError} from './error';
import {SwContentNodesFetchFailureError, SwNoArmadaNodes} from './error';
import {MsgContentChecksumMismatch, MsgContentNodeFetchFailure} from './msg';
import {NodeRegistry} from './registry';

Expand All @@ -23,7 +23,7 @@ class ThrowingFetcher {
}

export class ArmadaLazyAssetGroup extends LazyAssetGroup {
private static readonly TIMEOUT_MS = 250;
static readonly TIMEOUT_MS = 200;

constructor(
adapter: Adapter, idle: IdleScheduler, config: AssetGroupConfig, hashes: Map<string, string>,
Expand Down Expand Up @@ -60,6 +60,11 @@ export class ArmadaLazyAssetGroup extends LazyAssetGroup {
*/
async fetchContent(url: string): Promise<Response> {
const nodes = await this.registry.allNodes(true);

if (nodes.length === 0) {
throw new SwNoArmadaNodes(`No nodes available`);
}

let successfulResponse: Response | null = null;
let completedRequests = 0;
const controllers: AbortController[] = [];
Expand Down
Loading

0 comments on commit ad5ad55

Please sign in to comment.