Skip to content

Commit

Permalink
fix: make the contact info logs for the sync health job richer (#2338)
Browse files Browse the repository at this point in the history
It's currently hard to tell what state the contact info is in if the rpc
address is not present. Differentiate the error states better in the
logging.

## Merge Checklist

_Choose all relevant options below by adding an `x` now or at any time
before submitting for review_

- [x] PR title adheres to the [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) standard
- [ ] PR has a
[changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets)
- [x] PR has been tagged with a change label(s) (i.e. documentation,
feature, bugfix, or chore)
- [ ] PR includes
[documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs)
if necessary.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on improving error handling and simplifying the return
values related to `contactInfo` in the `syncHealthJob.ts` file.

### Detailed summary
- Replaced returning `undefined` when `contactInfo` is missing with
returning the string `"Missing contact info"`.
- Changed the return value for `contactInfo` to directly return
`contactInfo.contactInfo`.
- Updated the error message to exclude `contactInfo` details in the
logging.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
aditiharini authored Sep 26, 2024
1 parent 12e8c05 commit 8f4e8e4
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions apps/hubble/src/network/sync/syncHealthJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,12 @@ export class MeasureSyncHealthJobScheduler {
const contactInfo = this._metadataRetriever._syncEngine.getContactInfoForPeerId(peer.identifier);

if (!contactInfo) {
return undefined;
}

const rpcAddress = contactInfo.contactInfo.rpcAddress;
if (rpcAddress) {
const addressInfo = addressInfoFromGossip(rpcAddress);

if (addressInfo.isErr()) {
return undefined;
}

return addressInfoToString(addressInfo.value);
return "Missing contact info";
}

return contactInfo;
return contactInfo.contactInfo;
} else {
return undefined;
return peer.identifier;
}
}

Expand Down Expand Up @@ -235,8 +224,9 @@ export class MeasureSyncHealthJobScheduler {
{
peerId: peer.identifier,
err: syncHealthMessageStats.error,
contactInfo,
},
`Error computing SyncHealth: ${syncHealthMessageStats.error}. Contact info: ${contactInfo}`,
`Error computing SyncHealth: ${syncHealthMessageStats.error}.`,
);
continue;
}
Expand Down

0 comments on commit 8f4e8e4

Please sign in to comment.