Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): scope Sentry user per-request via withIsolationScope

justin654d03f60cad
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 0d67199be..af4f99048 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -580,7 +580,7 @@ export function createApp() {
) {
return next();
}
- return Sentry.withScope(async () => {
+ return Sentry.withIsolationScope(async () => {
Sentry.setUser(null);
try {
await authenticateApiRequest(c);
diff --git a/apps/api/src/utils/authenticate-api-request.ts b/apps/api/src/utils/authenticate-api-request.ts
index 908f099f7..5b8a4230a 100644
--- a/apps/api/src/utils/authenticate-api-request.ts
+++ b/apps/api/src/utils/authenticate-api-request.ts
@@ -5,9 +5,9 @@ import { HTTPException } from "hono/http-exception";
import { auth } from "../auth";
import { verifyApiKey } from "./verify-api-key";
-// User is tagged on Sentry's current scope; the per-request scope is forked
-// by Sentry.withScope in the api.use("*", ...) middleware, so this only
-// affects the in-flight request.
+// User is tagged on Sentry's isolation scope; the per-request isolation
+// scope is forked by Sentry.withIsolationScope in the api.use("*", ...)
+// middleware, so this only affects the in-flight request.
function attachUserToScope(userId: string) {
Sentry.setUser({ id: userId });
}