Skip to content

Commit

Permalink
Stop reporting block height too low for RPC error to Sentry.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 30, 2023
1 parent bf3ba26 commit ebb0bfa
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/scripts/export/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const main = async () => {
return blockHeightToTimeCache.get(blockHeight) ?? 0
}

// This may fail if the RPC does not have the block info at this height
// anymore (i.e. if it's too old and the RPC pruned it)
const loadIntoCache = async () => {
const {
header: { time },
Expand All @@ -87,16 +89,23 @@ const main = async () => {
JSON.stringify(trace, null, 2) +
'\n-------'
)
Sentry.captureException(err, {
tags: {
type: 'failed-get-block',
script: 'export',
},
extra: {
trace,
blockHeight,
},
})

// Only log to Sentry if not block height unavailable error.
if (
!(err instanceof Error) ||
!err.message.includes('must be less than or equal to the current')
) {
Sentry.captureException(err, {
tags: {
type: 'failed-get-block',
script: 'export',
},
extra: {
trace,
blockHeight,
},
})
}

// Set to 0 on failure so we can continue.
blockHeightToTimeCache.set(blockHeight, 0)
Expand Down

0 comments on commit ebb0bfa

Please sign in to comment.