Skip to content

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jan 14, 2026

A customer experienced the following issue on iOS Safari 18.6.2: TypeError: WeakMap keys must be objects or non-registered symbols.

The culprit is probably in web vitals initUnique function (which is vendored in).

This fix adds a try/catch to handle edge cases where invalid keys are passed to WeakMap, returning a new instance without caching when validation fails.

Closes #18810 (added automatically)

// --- START Sentry-custom code (try/catch wrapping) ---
// Fix for cases where identityObj is not a valid key for WeakMap (sometimes a problem in Safari)
// Just return a new instance without caching it in instanceMap
return new ClassObj();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for fix PR per review rules

Low Severity · Bugbot Rules

Per the review rules: "When reviewing a fix PR, check if the PR includes at least one unit, integration or e2e test that tests the regression this PR fixes." This fix PR adds error handling for invalid WeakMap keys in Safari but the diff contains no accompanying test to verify the fix works correctly. A test that simulates the Safari TypeError scenario would help prevent regressions.

Fix in Cursor Fix in Web

return instanceMap.get(identityObj)! as T;
} catch (e) {
// --- START Sentry-custom code (try/catch wrapping) ---
// Fix for cases where identityObj is not a valid key for WeakMap (sometimes a problem in Safari)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Is this issue easily reproducible? If so it'd be nice if we can somehow add a E2E test, if not I'm fine as is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, sadly it's not :/

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.05 kB - -
@sentry/browser - with treeshaking flags 23.58 kB - -
@sentry/browser (incl. Tracing) 41.81 kB +0.03% +9 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.39 kB +0.02% +9 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.41 kB +0.01% +8 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.13 kB +0.01% +6 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.11 kB +0.01% +8 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.31 kB +0.01% +6 B 🔺
@sentry/browser (incl. Feedback) 41.77 kB - -
@sentry/browser (incl. sendFeedback) 29.73 kB - -
@sentry/browser (incl. FeedbackAsync) 34.73 kB - -
@sentry/browser (incl. Metrics) 26.16 kB - -
@sentry/browser (incl. Logs) 26.3 kB - -
@sentry/browser (incl. Metrics & Logs) 26.96 kB - -
@sentry/react 26.78 kB - -
@sentry/react (incl. Tracing) 44.02 kB +0.03% +10 B 🔺
@sentry/vue 29.5 kB - -
@sentry/vue (incl. Tracing) 43.61 kB +0.02% +8 B 🔺
@sentry/svelte 25.06 kB - -
CDN Bundle 27.57 kB - -
CDN Bundle (incl. Tracing) 42.57 kB +0.04% +14 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.27 kB +0.02% +10 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 84.68 kB +0.01% +8 B 🔺
CDN Bundle - uncompressed 80.82 kB - -
CDN Bundle (incl. Tracing) - uncompressed 126.23 kB +0.03% +27 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 242.77 kB +0.02% +27 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 255.56 kB +0.02% +27 B 🔺
@sentry/nextjs (client) 46.38 kB +0.02% +9 B 🔺
@sentry/sveltekit (client) 42.19 kB +0.03% +10 B 🔺
@sentry/node-core 51.86 kB - -
@sentry/node 162.1 kB -0.01% -1 B 🔽
@sentry/node - without tracing 93.29 kB - -
@sentry/aws-serverless 108.78 kB - -

View base workflow run

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing! As discussed, it's not ideal that we can't repo this but I think in this case, let's merge and release it and check back with the affected customer if it fixes the issue.

@s1gr1d s1gr1d merged commit 7a975c9 into develop Jan 14, 2026
160 checks passed
@s1gr1d s1gr1d deleted the sig/web-vitals-fix branch January 14, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web-vitals): Add error handling for invalid object keys in WeakMap

5 participants