From 9fb6e2bc6b07b537bfb7b91b2e22387a08edd1e1 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Mon, 10 Jul 2023 15:01:55 +0200 Subject: [PATCH] Disable Sentry for dev mode The load function ends up getting called multiple times when wrapping it with Sentry. Turning it off for now, but should be investigated. --- src/lib/vbranches/BranchStoresCache.ts | 4 ---- src/routes/+layout.ts | 13 ++++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/vbranches/BranchStoresCache.ts b/src/lib/vbranches/BranchStoresCache.ts index 717a2e058..c93355f3e 100644 --- a/src/lib/vbranches/BranchStoresCache.ts +++ b/src/lib/vbranches/BranchStoresCache.ts @@ -14,10 +14,6 @@ export class BranchStoresCache { remoteBranchStores: Map>> = new Map(); targetBranchStores: Map>> = new Map(); - constructor() { - console.log('WHY IS THIS CALLED ALL THE TIME'); - } - getVirtualBranchStore(projectId: string) { const cachedStore = this.virtualBranchStores.get(projectId); if (cachedStore) { diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index af2f869f8..43c8a8877 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -10,14 +10,21 @@ export const ssr = false; export const prerender = true; export const csr = true; -export const load: LayoutLoad = wrapLoadWithSentry(({ fetch }) => { +import { dev } from '$app/environment'; + +// It turns out that this function gets called on every navigation when wrapped with Sentry. We +// don't know why it happens, but we should investigate if it happens in prod as well as dev. +// I examined the call stack and found a section suggesting it might not happen in prod. +// TODO(mattias): Investigate and decide what to do +function loadFn({ fetch: realFetch }: { fetch: typeof fetch }) { log.setup(); return { projects: api.projects.Projects(), - cloud: api.CloudApi({ fetch }), + cloud: api.CloudApi({ fetch: realFetch }), branchStoresCache: new BranchStoresCache(), posthog: Posthog(), sentry: Sentry(), userSettings: loadUserSettings() }; -}); +} +export const load: LayoutLoad = dev ? loadFn : wrapLoadWithSentry(loadFn);