Skip to content

Commit 0a50a53

Browse files
committed
fix(v8/svelte): Guard component tracking beforeUpdate call
1 parent b6a4a4a commit 0a50a53

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/svelte/src/performance.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';
22
import type { Span } from '@sentry/core';
33
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
44

5-
import { startInactiveSpan } from '@sentry/core';
5+
import { logger, startInactiveSpan } from '@sentry/core';
66
import { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';
77
import type { TrackComponentOptions } from './types';
88

@@ -36,7 +36,13 @@ export function trackComponent(options?: TrackComponentOptions): void {
3636
}
3737

3838
if (mergedOptions.trackUpdates) {
39-
recordUpdateSpans(componentName);
39+
try {
40+
recordUpdateSpans(componentName);
41+
} catch (e) {
42+
logger.warn(
43+
"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.",
44+
);
45+
}
4046
}
4147
}
4248

0 commit comments

Comments
 (0)