diff --git a/packages/light-client/src/index.ts b/packages/light-client/src/index.ts index ca7636d1a9a1..b38cc66894ae 100644 --- a/packages/light-client/src/index.ts +++ b/packages/light-client/src/index.ts @@ -244,21 +244,21 @@ export class Lightclient { } } - // 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 if (this.runStatus.code !== RunStatusCode.started) { const controller = new AbortController(); this.updateRunStatus({code: RunStatusCode.started, controller}); this.logger.debug("Started tracking the head"); + // 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); + } + this.transport.onOptimisticUpdate(this.processOptimisticUpdate.bind(this)); this.transport.onFinalityUpdate(this.processFinalizedUpdate.bind(this)); }