Skip to content

Persist Change Bundle Location host setting#57425

Open
Phecda wants to merge 1 commit into
react:mainfrom
Phecda:fix/persist-change-bundle-location
Open

Persist Change Bundle Location host setting#57425
Phecda wants to merge 1 commit into
react:mainfrom
Phecda:fix/persist-change-bundle-location

Conversation

@Phecda

@Phecda Phecda commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary:

Persist Change Bundle Location updates to the same debug_http_host preference used by the Android Dev Settings screen.

Previously, Change Bundle Location only updated the in-memory PackagerConnectionSettings host override. After killing and restarting the app process, the host was read again from SharedPreferences, so the change was lost.

Changelog:

[ANDROID] [FIXED] - Persist Change Bundle Location debug server host changes

Test Plan:

Verified with RNTester debugOptimized on Android:

  1. Installed and launched RNTester on a physical Android device.
  2. Opened the React Native Dev Menu.
  3. Changed the bundle location using Change Bundle Location.
  4. Killed and restarted the app process.
  5. Confirmed the updated host is still used after restart.

Change Bundle Location updates PackagerConnectionSettings.debugServerHost, but the setter only updated the in-memory cached host. After the app process restarted, PackagerConnectionSettings read debug_http_host from default SharedPreferences and fell back to the previous value.

Persist the selected host to the same debug_http_host preference used by DevSettingsActivity so both entry points share the same storage path.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 3, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 3, 2026

@Abbondanzo Abbondanzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is actually leftovers from a migration away from persisting the bundle location to disk (#54139). The shared preferences read is only there for legacy reasons, but given that iOS is still writing to disk I think it's fine to reintroduce such a change. Left a few review comments to fix up first

}
set(host) {
if (host.isEmpty()) {
_cachedOrOverrideHost = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: rather than storing a null string, can you have this remove the string altogether?

}

public open fun resetDebugServerHost() {
_cachedOrOverrideHost = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The preferences should be cleared here too, but the constructor would have to updated to not call this method and blast this away each time

Suggested change
preferences.edit().remove(PREFS_DEBUG_SERVER_HOST_KEY).apply()
_cachedOrOverrideHost = null

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants