Skip to content

Keep dev-server host validation compatible across OkHttp versions - #60317

Closed
cipolleschi wants to merge 1 commit into
mainfrom
cipolleschi/fix-dev-server-okhttp3
Closed

cipolleschi wants to merge 1 commit into
mainfrom
cipolleschi/fix-dev-server-okhttp3

Conversation

@cipolleschi

@cipolleschi cipolleschi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow up to #58971 without changing its connection lifecycle fix.

Validate a dev-server host through Request.Builder.url, which is available in both OkHttp 3 and newer versions. The previous Kotlin companion extension is available only in newer OkHttp versions. Invalid URLs still return false; the HTTP/HTTPS scheme selection and accepted/rejected host cases are unchanged.

Keep the loopback and Android-emulator IP literals in the regression tests, and suppress HardcodedIPAddressUse only on the methods that deliberately use those fixtures.

Changelog

[Android][Fixed] - Keep dev-server host validation compatible with OkHttp 3

Test plan

Validation supplied with the follow-up bundle:

  • The existing host-validation, packager sequencing and WebSocket lifecycle regressions passed: 25 tests, zero failures or skips, using OkHttp 4.10.0.
  • The compatibility change built successfully in a consumer selecting OkHttp 3.14.9.

Fresh checks on upstream main at 2fed45cd45c:

  • git apply --check source-only.patch passed; all three resulting files match the supplied patch byte for byte.
  • git diff --check passed.
  • Pinned ktfmt 0.59.0 passed for all three changed files:
java -jar node_modules/ktfmt/lib/ktfmt.jar --do-not-remove-unused-imports --dry-run --set-exit-if-changed \
  packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/DevSupportHttpClient.kt \
  packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/DevServerHelperTest.kt \
  packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/inspector/DevSupportHttpClientTest.kt

The fresh local Gradle run stopped before executing tests: buildCodegenCLI could not install dependencies because the registry proxy returned HTTP 503 (tunneling socket could not be established). Command attempted:

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
  --tests com.facebook.react.devsupport.inspector.DevSupportHttpClientTest \
  --tests com.facebook.react.devsupport.DevServerHelperTest \
  --tests com.facebook.react.packagerconnection.ReconnectingWebSocketTest \
  --tests com.facebook.react.packagerconnection.JSPackagerClientTest \
  -Preact.internal.useHermesStable=true -PreactNativeArchitectures=arm64-v8a --console=plain

Full app builds and device UI testing were not run locally. GitHub CI will validate the upstream follow-up.

@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 Nov 26, 2026
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 26, 2026
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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant