Skip to content

Commit

Permalink
Fix spammy "Core exited" Sentry error (#1606)
Browse files Browse the repository at this point in the history
* Fix spammy "Core exited" Sentry event

* update report last 20 log lines
  • Loading branch information
juliangruber authored Jun 10, 2024
1 parent bf91682 commit 5d7b3dd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions main/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ async function run (ctx) {
}
}

let lastCrashReportedAt = 0
/**
* @param {unknown} err
* @param {any} scopeFn
*/
function maybeReportErrorToSentry (err, scopeFn) {
const now = Date.now()
if (now - lastCrashReportedAt < 4 /* HOURS */ * 3600_000) return
lastCrashReportedAt = now
console.error(
'Reporting the problem to Sentry for inspection by the Station team.'
)
Sentry.captureException(err, scopeFn)
}

/**
* @param {Context} ctx
*/
Expand Down Expand Up @@ -154,9 +169,9 @@ async function start (ctx) {
throw new Error('Invalid Filecoin wallet address')
}

Sentry.captureException('Core exited', scope => {
maybeReportErrorToSentry('Core exited', (/** @type {any} */ scope) => {
// Sentry UI can't show the full 100 lines
scope.setExtra('logs', logs.getLastLines(10))
scope.setExtra('logs', logs.getLastLines(20))
scope.setExtra('reason', exitReason)
return scope
})
Expand Down

0 comments on commit 5d7b3dd

Please sign in to comment.