Skip to content

Commit fb922cd

Browse files
fix(worker): capture API route errors in Sentry (#1439)
1 parent 53360a8 commit fb922cd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/backend/src/api.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { PrismaClient, RepoIndexingJobType } from '@sourcebot/db';
2+
import * as Sentry from '@sentry/node';
23
import { hasEntitlement } from './entitlements.js';
34
import { createLogger, doesIdpSupportPermissionSyncing, env } from '@sourcebot/shared';
4-
import express, { Request, Response } from 'express';
5+
import express, { NextFunction, Request, Response } from 'express';
56
import 'express-async-errors';
67
import * as http from "http";
78
import { ConnectionManager } from './connectionManager.js';
@@ -45,6 +46,11 @@ export class Api {
4546
app.post('/api/trigger-account-permission-sync', this.triggerAccountPermissionSync.bind(this));
4647
app.post(`/api/experimental/add-github-repo`, this.experimental_addGithubRepo.bind(this));
4748

49+
app.use((error: unknown, _req: Request, _res: Response, next: NextFunction) => {
50+
Sentry.captureException(error);
51+
next(error);
52+
});
53+
4854
this.server = app.listen(PORT, () => {
4955
logger.debug(`API server is running on port ${PORT}`);
5056
});

0 commit comments

Comments
 (0)