Skip to content

Commit

Permalink
🐛 fix sentry error capturing for algolia indexing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Jan 31, 2025
1 parent 1401cf2 commit 3e05a9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
9 changes: 5 additions & 4 deletions baker/algolia/indexChartsToAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// set up before any errors are thrown.
import "../../serverUtils/instrument.js"

import * as Sentry from "@sentry/node"
import * as db from "../../db/db.js"
import { ALGOLIA_INDEXING } from "../../settings/serverSettings.js"
import { getAlgoliaClient } from "./configureAlgolia.js"
Expand All @@ -27,9 +28,9 @@ const indexChartsToAlgolia = async () => {
await index.replaceAllObjects(records)
}

process.on("unhandledRejection", (e) => {
console.error(e)
indexChartsToAlgolia().catch(async (e) => {
console.error("Error in indexChartsToAlgolia:", e)
Sentry.captureException(e)
await Sentry.close()
process.exit(1)
})

void indexChartsToAlgolia()
9 changes: 5 additions & 4 deletions baker/algolia/indexExplorerViewsAndChartsToAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// set up before any errors are thrown.
import "../../serverUtils/instrument.js"

import * as Sentry from "@sentry/node"
import * as db from "../../db/db.js"
import { ALGOLIA_INDEXING } from "../../settings/serverSettings.js"
import { getAlgoliaClient } from "./configureAlgolia.js"
Expand Down Expand Up @@ -55,9 +56,9 @@ const indexExplorerViewsAndChartsToAlgolia = async () => {
console.log(`Indexing complete`)
}

process.on("unhandledRejection", (e) => {
console.error(e)
indexExplorerViewsAndChartsToAlgolia().catch(async (e) => {
console.error("Error in indexExplorerViewsAndChartsToAlgolia:", e)
Sentry.captureException(e)
await Sentry.close()
process.exit(1)
})

void indexExplorerViewsAndChartsToAlgolia()
9 changes: 5 additions & 4 deletions baker/algolia/indexExplorerViewsToAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// set up before any errors are thrown.
import "../../serverUtils/instrument.js"

import * as Sentry from "@sentry/node"
import * as db from "../../db/db.js"
import { ALGOLIA_INDEXING } from "../../settings/serverSettings.js"
import { getAlgoliaClient } from "./configureAlgolia.js"
Expand Down Expand Up @@ -30,9 +31,9 @@ const indexExplorerViewsToAlgolia = async () => {
console.log(`Indexing complete`)
}

process.on("unhandledRejection", (e) => {
console.error(e)
indexExplorerViewsToAlgolia().catch(async (e) => {
console.error("Error in indexExplorerViewsToAlgolia:", e)
Sentry.captureException(e)
await Sentry.close()
process.exit(1)
})

void indexExplorerViewsToAlgolia()
13 changes: 9 additions & 4 deletions baker/algolia/indexPagesToAlgolia.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// This should be imported as early as possible so the global error handler is
// set up before any errors are thrown.
import "../../serverUtils/instrument.js"

import * as Sentry from "@sentry/node"
import * as db from "../../db/db.js"
import { ALGOLIA_INDEXING } from "../../settings/serverSettings.js"
import { getAlgoliaClient } from "./configureAlgolia.js"
Expand Down Expand Up @@ -25,9 +30,9 @@ const indexPagesToAlgolia = async () => {
process.exit(0)
}

process.on("unhandledRejection", (e) => {
console.error(e)
indexPagesToAlgolia().catch(async (e) => {
console.error("Error in indexPagesToAlgolia:", e)
Sentry.captureException(e)
await Sentry.close()
process.exit(1)
})

void indexPagesToAlgolia()

0 comments on commit 3e05a9b

Please sign in to comment.