Skip to content

Commit

Permalink
feat: Always try to fetch optimistic update when starting lc
Browse files Browse the repository at this point in the history
Currently fetching an optimistic update at client start happens only if a sync is needed. 
The proposed change tries to fetch an optimistic update even if no sync is needed, e.g. the client was initialized with a recent checkpoint
  • Loading branch information
rdvorkin authored Sep 21, 2023
1 parent 900f6a7 commit 5d242d3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/light-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ export class Lightclient {
await new Promise((r) => setTimeout(r, ON_ERROR_RETRY_MS));
continue;
}
}

// Fetch latest optimistic head to prevent a potential 12 seconds lag between syncing and getting the first head,
// Don't retry, this is a non-critical UX improvement
try {
const update = await this.transport.getOptimisticUpdate();
this.processOptimisticUpdate(update.data);
} catch (e) {
this.logger.error("Error fetching getLatestHeadUpdate", {currentPeriod}, e as Error);
}
// Fetch latest optimistic head to prevent a potential 12 seconds lag between syncing and getting the first head,
// Don't retry, this is a non-critical UX improvement
try {
const update = await this.transport.getOptimisticUpdate();
this.processOptimisticUpdate(update.data);
} catch (e) {
this.logger.error("Error fetching getLatestHeadUpdate", {currentPeriod}, e as Error);
}

// After successfully syncing, track head if not already
Expand Down

0 comments on commit 5d242d3

Please sign in to comment.