Skip to content

fix(feedback): Guard show/hide against uninitialized _setVisibility#6435

Open
antonis wants to merge 2 commits into
mainfrom
fix/feedback-form-manager-uninitialized-setvisibility
Open

fix(feedback): Guard show/hide against uninitialized _setVisibility#6435
antonis wants to merge 2 commits into
mainfrom
fix/feedback-form-manager-uninitialized-setvisibility

Conversation

@antonis

@antonis antonis commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • Bugfix

Description

FeedbackFormManager._setVisibility (and the same static on FeedbackButtonManager / ScreenshotButtonManager) was declared without a default value. It only becomes defined when FeedbackFormProvider's constructor calls initialize(). Any call to showFeedbackForm() / hideFeedbackForm() / showFeedbackButton() / showScreenshotButton() before that provider has mounted hits an undefined static, and the internal guard if (this._setVisibility !== NOOP_SET_VISIBILITY) evaluates truthy, so the code calls undefined(true) and throws:

TypeError: this._setVisibility is not a function
  at FeedbackManager.show (@sentry/react-native/dist/js/feedback/FeedbackFormManager.js)

The console.warn fallback that instructs the user to add Sentry.wrap(RootComponent) was unreachable in this state.

The fix defaults _setVisibility to NOOP_SET_VISIBILITY at declaration. The guard now correctly detects the never-initialized state and falls through to the warn branch. Applies to all three subclasses via static-property inheritance.

Motivation and Context

Reported crashes in the SDK Crashes React Native project — SDK-CRASHES-REACT-NATIVE-62C (11 users / 42 events across 8.7.0 – 8.16.0, both iOS and Android). All events show the crash originating during React render — matching the case where a user component calls showFeedbackForm() in its own render/effect before the provider has finished mounting.

The existing "does not throw" test masked the bug because beforeEach calls resetFeedbackFormManager(), which sets _setVisibility to NOOP_SET_VISIBILITY and hides the never-initialized state that production users actually hit.

How did you test it?

  • Added two regression tests under jest.isolateModules that load FeedbackFormManager fresh (no prior initialize/reset) and assert showFeedbackForm() / FeedbackFormManager.hide() do not throw and warn as intended.
  • Verified the new tests fail on main (produce the exact production TypeError) and pass with the fix.
  • Full @sentry/react-native Jest suite: 1699/1699 pass.
  • yarn lint:lerna: clean.
  • yarn circularDepCheck: clean.

Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • Review from the native team if needed (N/A — TS-only)

Next steps

None.

antonis and others added 2 commits July 10, 2026 10:26
When Sentry.showFeedbackForm() (or the equivalent Button/Screenshot
show/hide) is called before FeedbackFormProvider has mounted and run
initialize(), the static _setVisibility was undefined. The guard
`_setVisibility !== NOOP_SET_VISIBILITY` evaluated true and the code
called undefined(true), throwing TypeError.

Default the static field to NOOP_SET_VISIBILITY at declaration so the
guard correctly falls through to the intended console.warn fallback.

Fixes SDK-CRASHES-REACT-NATIVE-62C

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(feedback): Guard show/hide against uninitialized _setVisibility by antonis in #6435
  • feat(tracing): Add reportFullyDisplayed() static API by antonis in #6419
  • feat(core): Track CaptureAppStartErrors adoption by antonis in #6429
  • feat(replay): Track mobile replay network capture adoption by antonis in #6428
  • feat(tracing): Track standalone app start adoption by antonis in #6427
  • feat(tracing): Track appLoaded and extendAppStart adoption by antonis in #6426
  • feat(tracing): Track wrapExpoRouterErrorBoundary adoption by antonis in #6425
  • feat(core): Track NavigationContainer adoption by antonis in #6424
  • feat(core): Track GlobalErrorBoundary adoption by antonis in #6421

🤖 This preview updates automatically when you update the PR.

@antonis

antonis commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@antonis

antonis commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@sentry review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2007909. Configure here.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Jul 10, 2026
@antonis antonis marked this pull request as ready for review July 10, 2026 08:40
@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 461.42 ms 508.62 ms 47.20 ms
Size 49.74 MiB 55.26 MiB 5.52 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f3215d3+dirty 411.11 ms 454.38 ms 43.27 ms
d2eadf8+dirty 414.64 ms 454.56 ms 39.92 ms
b0d3373+dirty 557.66 ms 579.42 ms 21.76 ms
27d9693+dirty 419.08 ms 469.12 ms 50.04 ms
4e0b819+dirty 420.56 ms 470.08 ms 49.52 ms
9474ead+dirty 411.45 ms 446.80 ms 35.35 ms
0bd8916+dirty 412.77 ms 451.31 ms 38.54 ms
f9c1ed4+dirty 431.00 ms 466.22 ms 35.22 ms
3d536d1+dirty 524.34 ms 547.32 ms 22.98 ms
04207c4+dirty 459.19 ms 518.54 ms 59.35 ms

App size

Revision Plain With Sentry Diff
f3215d3+dirty 48.30 MiB 53.49 MiB 5.19 MiB
d2eadf8+dirty 48.30 MiB 53.48 MiB 5.18 MiB
b0d3373+dirty 48.30 MiB 53.58 MiB 5.28 MiB
27d9693+dirty 49.74 MiB 55.09 MiB 5.34 MiB
4e0b819+dirty 49.74 MiB 54.81 MiB 5.07 MiB
9474ead+dirty 48.30 MiB 53.61 MiB 5.30 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
f9c1ed4+dirty 49.74 MiB 54.86 MiB 5.12 MiB
3d536d1+dirty 49.74 MiB 55.26 MiB 5.52 MiB
04207c4+dirty 43.75 MiB 48.12 MiB 4.37 MiB

@sentry

sentry Bot commented Jul 10, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.18.0 (98) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3843.26 ms 1216.38 ms -2626.88 ms
Size 4.98 MiB 6.53 MiB 1.55 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b0d3373+dirty 3842.49 ms 1218.49 ms -2624.00 ms
ef27341+dirty 3835.20 ms 1212.23 ms -2622.97 ms
e5bb5f6+dirty 3825.74 ms 1217.30 ms -2608.43 ms
44c8b3f+dirty 3849.24 ms 1209.94 ms -2639.31 ms
68672fc+dirty 3832.22 ms 1228.29 ms -2603.93 ms
5748023+dirty 3844.74 ms 1225.49 ms -2619.26 ms
6acdf1d+dirty 3835.35 ms 1218.30 ms -2617.06 ms
2c735cc+dirty 1223.33 ms 1224.38 ms 1.04 ms
100ce80+dirty 3843.57 ms 1226.46 ms -2617.12 ms
9210ae6+dirty 3834.11 ms 1216.64 ms -2617.47 ms

App size

Revision Plain With Sentry Diff
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
ef27341+dirty 5.15 MiB 6.68 MiB 1.53 MiB
e5bb5f6+dirty 4.98 MiB 6.51 MiB 1.53 MiB
44c8b3f+dirty 5.15 MiB 6.66 MiB 1.51 MiB
68672fc+dirty 5.15 MiB 6.71 MiB 1.55 MiB
5748023+dirty 5.15 MiB 6.68 MiB 1.53 MiB
6acdf1d+dirty 4.98 MiB 6.51 MiB 1.53 MiB
2c735cc+dirty 3.38 MiB 4.74 MiB 1.35 MiB
100ce80+dirty 5.15 MiB 6.67 MiB 1.51 MiB
9210ae6+dirty 5.15 MiB 6.68 MiB 1.53 MiB

@github-actions

Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3843.08 ms 1228.20 ms -2614.88 ms
Size 4.98 MiB 6.53 MiB 1.55 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b9bebee+dirty 3850.15 ms 1227.51 ms -2622.64 ms
3d377b5+dirty 1218.48 ms 1219.51 ms 1.03 ms
1a2e7e0+dirty 3842.49 ms 1220.04 ms -2622.45 ms
e5bb5f6+dirty 3826.14 ms 1212.24 ms -2613.90 ms
6acdf1d+dirty 3844.33 ms 1212.96 ms -2631.38 ms
41d6254+dirty 3845.71 ms 1224.51 ms -2621.20 ms
9210ae6+dirty 3815.93 ms 1214.14 ms -2601.79 ms
c004dae+dirty 3850.32 ms 1227.79 ms -2622.53 ms
4e0b819+dirty 3839.05 ms 1210.75 ms -2628.30 ms
0b5120f+dirty 3838.39 ms 1232.91 ms -2605.48 ms

App size

Revision Plain With Sentry Diff
b9bebee+dirty 5.15 MiB 6.68 MiB 1.53 MiB
3d377b5+dirty 3.38 MiB 4.76 MiB 1.38 MiB
1a2e7e0+dirty 4.98 MiB 6.46 MiB 1.49 MiB
e5bb5f6+dirty 4.98 MiB 6.51 MiB 1.53 MiB
6acdf1d+dirty 4.98 MiB 6.51 MiB 1.53 MiB
41d6254+dirty 5.15 MiB 6.70 MiB 1.54 MiB
9210ae6+dirty 5.15 MiB 6.68 MiB 1.53 MiB
c004dae+dirty 5.15 MiB 6.67 MiB 1.51 MiB
4e0b819+dirty 4.98 MiB 6.46 MiB 1.49 MiB
0b5120f+dirty 5.15 MiB 6.68 MiB 1.53 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 428.52 ms 486.76 ms 58.24 ms
Size 49.74 MiB 55.26 MiB 5.52 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms
d038a14+dirty 405.08 ms 444.36 ms 39.28 ms
68672fc+dirty 407.55 ms 442.96 ms 35.41 ms
ad66da3+dirty 411.49 ms 449.38 ms 37.89 ms
f170ec3+dirty 505.96 ms 551.88 ms 45.92 ms
27d9693+dirty 438.63 ms 514.08 ms 75.46 ms
41d6254+dirty 406.20 ms 445.52 ms 39.32 ms
68ae91b+dirty 515.04 ms 578.08 ms 63.04 ms
5ee78d6+dirty 411.18 ms 437.83 ms 26.65 ms
ae37560+dirty 428.96 ms 456.86 ms 27.90 ms

App size

Revision Plain With Sentry Diff
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB
d038a14+dirty 48.30 MiB 53.49 MiB 5.19 MiB
68672fc+dirty 48.30 MiB 53.61 MiB 5.31 MiB
ad66da3+dirty 48.30 MiB 53.49 MiB 5.19 MiB
f170ec3+dirty 48.30 MiB 53.57 MiB 5.26 MiB
27d9693+dirty 49.74 MiB 55.09 MiB 5.34 MiB
41d6254+dirty 48.30 MiB 53.60 MiB 5.30 MiB
68ae91b+dirty 49.74 MiB 54.79 MiB 5.05 MiB
5ee78d6+dirty 48.30 MiB 53.58 MiB 5.28 MiB
ae37560+dirty 48.30 MiB 53.60 MiB 5.29 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant