Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix don't report unactionable w3name request errors to Sentry #652

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import pRetry from 'p-retry'
import * as Name from 'w3name'
import { ethers } from 'ethers'
import * as SparkImpactEvaluator from '@filecoin-station/spark-impact-evaluator'
import { reportW3NameError } from './telemetry.js'

const {
// https://github.com/filecoin-station/contract-addresses
Expand Down Expand Up @@ -61,6 +62,14 @@ async function getContractsWithRetry ({ provider }) {

async function getContractAddresses () {
const name = Name.parse(CONTRACT_ADDRESSES_IPNS_KEY)
const revision = await Name.resolve(name)
let revision
try {
revision = await Name.resolve(name)
} catch (err) {
reportW3NameError()
// These errors aren't actionable
err.reportToSentry = false
throw err
}
return revision.value.split('\n').filter(Boolean)
}
11 changes: 10 additions & 1 deletion lib/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CarReader } from '@ipld/car'
import { validateBlock } from '@web3-storage/car-block-validator'
import { recursive as exporter } from 'ipfs-unixfs-exporter'
import * as tar from 'tar'
import { reportW3NameError } from './telemetry.js'

/** @typedef {import('unzip-stream').UnzipStreamEntry} UnzipStreamEntry */

Expand Down Expand Up @@ -106,7 +107,15 @@ export const installBinaryModule = async ({

async function getLatestCID (ipnsKey) {
const name = Name.parse(ipnsKey)
const revision = await Name.resolve(name)
let revision
try {
revision = await Name.resolve(name)
} catch (err) {
reportW3NameError()
// These errors aren't actionable
err.reportToSentry = false
throw err
}
// /ipfs/:cid
return revision.value.split('/').pop()
}
Expand Down
7 changes: 7 additions & 0 deletions lib/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,10 @@ export const runMachinesLoop = async ({ STATION_ID }) => {
await timers.setTimeout(24 * 3600 * 1000) // 1 day
}
}

export const reportW3NameError = () => {
const point = new Point('w3name-error')
point.stringField('version', pkg.version)
writeClient.writePoint(point)
writeClient.flush().catch(handleFlushError)
}
Loading