diff --git a/apps/hubble/src/network/sync/syncHealthJob.ts b/apps/hubble/src/network/sync/syncHealthJob.ts index 329b758298..bba7ee1249 100644 --- a/apps/hubble/src/network/sync/syncHealthJob.ts +++ b/apps/hubble/src/network/sync/syncHealthJob.ts @@ -4,7 +4,9 @@ import SyncEngine from "./syncEngine.js"; import { RpcMetadataRetriever, SyncEngineMetadataRetriever, SyncHealthProbe } from "../../utils/syncHealth.js"; import { HubInterface } from "hubble.js"; import { peerIdFromString } from "@libp2p/peer-id"; -import { bytesToHexString, HubResult, Message, UserDataType } from "@farcaster/hub-nodejs"; +import { bytesToHexString, Message, UserDataType } from "@farcaster/hub-nodejs"; +import { Result } from "neverthrow"; +import { SubmitError } from "../../utils/syncHealth.js"; const log = logger.child({ component: "SyncHealth", @@ -60,7 +62,7 @@ export class MeasureSyncHealthJobScheduler { return peers; } - processSumbitResults(results: HubResult[], peerId: string) { + processSumbitResults(results: Result[], peerId: string) { let numSuccesses = 0; let numErrors = 0; for (const result of results) { @@ -80,7 +82,12 @@ export class MeasureSyncHealthJobScheduler { numSuccesses += 1; } else { - log.info({ errMessage: result.error.message, peerId }, "Failed to submit message via SyncHealth"); + const hashString = bytesToHexString(result.error.originalMessage.hash); + const hash = hashString.isOk() ? hashString.value : "unable to show hash"; + log.info( + { errMessage: result.error.hubError.message, peerId, hash }, + "Failed to submit message via SyncHealth", + ); numErrors += 1; } diff --git a/apps/hubble/src/utils/syncHealth.ts b/apps/hubble/src/utils/syncHealth.ts index 0516a218e3..f94299bbb4 100644 --- a/apps/hubble/src/utils/syncHealth.ts +++ b/apps/hubble/src/utils/syncHealth.ts @@ -21,11 +21,12 @@ import { appendFile } from "fs/promises"; import { addressInfoFromGossip, addressInfoToString } from "./p2p.js"; import { SyncId, timestampToPaddedTimestampPrefix } from "../network/sync/syncId.js"; -import { err, ok } from "neverthrow"; +import { err, ok, Result } from "neverthrow"; import { MAX_VALUES_RETURNED_PER_SYNC_ID_REQUEST, toTrieNodeMetadataResponse } from "../rpc/server.js"; import SyncEngine from "../network/sync/syncEngine.js"; import { HubInterface } from "hubble.js"; +export type SubmitError = { hubError: HubError; originalMessage: Message }; class SyncHealthMessageStats { primaryNumMessages: number; peerNumMessages: number; @@ -46,8 +47,8 @@ class SyncHealthMessageStats { class Stats { syncHealthMessageStats: SyncHealthMessageStats; - resultsUploadingToPeer: HubResult[]; - resultsUploadingToPrimary: HubResult[]; + resultsUploadingToPeer: Result[]; + resultsUploadingToPrimary: Result[]; primary: string; peer: string; startTime: Date; @@ -59,8 +60,8 @@ class Stats { primary: string, peer: string, syncHealthMessageStats: SyncHealthMessageStats, - resultsUploadingToPeer: HubResult[], - resultsUploadingToPrimary: HubResult[], + resultsUploadingToPeer: Result[], + resultsUploadingToPrimary: Result[], ) { this.startTime = startTime; this.stopTime = stopTime; @@ -88,7 +89,7 @@ class Stats { const errorReasons = new Set(); for (const error of this.errorResults(who)) { if (error.isErr()) { - errorReasons.add(error.error.message); + errorReasons.add(error.error.hubError.message); } } return [...errorReasons]; @@ -505,7 +506,10 @@ export class SyncHealthProbe { const results = []; for (const message of messages.value.messages) { const result = await metadataRetrieverMissingMessages.submitMessage(message); - results.push(result); + const augmentedResult = result.mapErr((err) => { + return { hubError: err, originalMessage: message }; + }); + results.push(augmentedResult); } return ok(results);