-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[reupload] - added: Websocket Module setCustomClientBuilder #37798
Conversation
Hi @MO-Lewis! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Base commit: 04ad34d |
FYI I've just signed the CLA, I'm guessing it'll update the PR shortly 😅 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
public static interface CustomClientBuilder { | ||
public void apply(OkHttpClient.Builder builder); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For backwards compatibility, can you keep the old interface name here, but mark it as deprecated. We can then remove it in a future release
public static interface CustomClientBuilder extends com.facebook.react.modules.network.CustomClientBuilder {}
Please note the deprecation of the old interface in the changelog entry, other than that, this seems good to me. |
…ecation, as suggested here: facebook#37798 (review)
Hi @javache! I've just made that change for you, I believe this is what you wanted. If there's something not right about the change I've made, or have any additional feedback, please let me know. 😄 Thanks! |
…up to commit `52698e758d1454afc74541e5507ac16dd6154386` Merge remote-tracking branch 'upstream/main'
Just did another commit to merge everything and pull recent changes from the main React Native repo up to commit |
/** | ||
* @deprecated To be removed in a future release. See https://github.com/facebook/react-native/pull/37798#pullrequestreview-1518338914 | ||
*/ | ||
public static interface CustomClientBuilder extends com.facebook.react.modules.network.CustomClientBuilder { | ||
public void apply(OkHttpClient.Builder builder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be an empty interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in latest commit; resolve if sufficient.
|
||
public interface CustomClientBuilder { | ||
public void apply(OkHttpClient.Builder builder); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: empty new line at end of file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended in latest commit; resolve if sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, few more changes.
/** | ||
* @deprecated To be removed in a future release. See https://github.com/facebook/react-native/pull/37798#pullrequestreview-1518338914 | ||
*/ | ||
public static interface CustomClientBuilder extends com.facebook.react.modules.network.CustomClientBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the API's in this class reference com.facebook.react.modules.network.CustomClientBuilder
, not this CustomClientBuilder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I'm not too sure what you mean by this. Does this mean you'd like com.facebook.react.modules.network.CustomClientBuilder
explicitly imported at the top of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anywhere in this Java file where it references CustomClientBuilder
it will use the old deprecated interface, you could point at the shared interface instead, and will prevent people from upgrading their code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @javache, I believe I've implemented what you'd like. I've changed:
public static void setCustomClientBuilder(CustomClientBuilder ccb) {
to
public static void setCustomClientBuilder(com.facebook.react.modules.network.CustomClientBuilder ccb) {
Does this cover what you've requested? Anything else, just let me know 🙂
@@ -0,0 +1,75 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has been incorrectly merged back in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies! Removed in latest commit; resolve if sufficient.
Changelog: - Added empty new line at end of file on `CustomClientBuilder.java` - Removed accidentally-added `ReactNativeFlipper.java` file. - Made deprecated `CustomClientBuilder` interface empty.
@@ -167,9 +167,10 @@ public static void setCustomClientBuilder(CustomClientBuilder ccb) { | |||
customClientBuilder = ccb; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly github doesn't allow you to comment on unchanged lines, but line 168 here needs to be com.facebook.react.modules.network.CustomClientBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Javache, I've implemented and replied to this here
Changelog: - Implemented feedback to point all `CustomClientBuilder` references in `NetworkingModule,java` to `com.facebook.react.modules.network.CustomClientBuilder`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of customClientBuilder in NetworkingModule also needs to become com.facebook.react.modules.network.CustomClientBuilder
Thanks for the heads up! I've just made that change now. |
@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MO-Lewis could you rebase on top of the latest main
as the CI should be green now
All done! CI is rerunning for you now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit @MO-Lewis and we should be able to merge it
/** | ||
* @deprecated To be removed in a future release. See https://github.com/facebook/react-native/pull/37798#pullrequestreview-1518338914 | ||
*/ | ||
public static interface CustomClientBuilder extends com.facebook.react.modules.network.CustomClientBuilder {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also @Deprecate
this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Just added that, CICD re-running now.
Changelog: - Added `@Deprecated` to `CustomClientBuilder` in `NetworkingModule.java
Changelog: - Added `@Deprecated` to `CustomClientBuilder` in `NetworkingModule.java`
@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary: Added code previously added in the following PR: facebook#28659. The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: facebook#37770 (comment), I'm opening a new PR with the same code to get this merged into master / main. Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in facebook#37770 and the other linked issues nested inside of this issue. **Original summary is as follows:** With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient. ## Changelog: [Android] [Added] - Websocket Module setCustomClientBuilder <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: facebook#37798 Test Plan: **From the original PR:** You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`: ``` import okhttp3.OkHttpClient; import java.util.concurrent.TimeUnit; import com.facebook.react.modules.network.CustomClientBuilder; import com.facebook.react.modules.websocket.WebsocketModule; public class MainActivity extends ReactFragmentActivity { Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); RNBootSplash.init(R.drawable.launch_screen, MainActivity.this); WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() { Override public void apply(OkHttpClient.Builder builder) { builder.connectTimeout(0, TimeUnit.MILLISECONDS); } }); } ... ``` Reviewed By: cortinico Differential Revision: D47468613 Pulled By: javache fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
Summary: Added code previously added in the following PR: facebook#28659. The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: facebook#37770 (comment), I'm opening a new PR with the same code to get this merged into master / main. Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in facebook#37770 and the other linked issues nested inside of this issue. **Original summary is as follows:** With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient. [Android] [Added] - Websocket Module setCustomClientBuilder <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: facebook#37798 Test Plan: **From the original PR:** You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`: ``` import okhttp3.OkHttpClient; import java.util.concurrent.TimeUnit; import com.facebook.react.modules.network.CustomClientBuilder; import com.facebook.react.modules.websocket.WebsocketModule; public class MainActivity extends ReactFragmentActivity { Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); RNBootSplash.init(R.drawable.launch_screen, MainActivity.this); WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() { Override public void apply(OkHttpClient.Builder builder) { builder.connectTimeout(0, TimeUnit.MILLISECONDS); } }); } ... ``` Reviewed By: cortinico Differential Revision: D47468613 Pulled By: javache fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
Summary:
Added code previously added in the following PR: #28659.
The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: #37770 (comment), I'm opening a new PR with the same code to get this merged into master / main.
Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently impossible to build React Native from source when running on a Windows machine, as evidenced in #37770 and the other linked issues nested inside of this issue.
Original summary is as follows:
With
NetworkModule.setCustomClientBuilder
we can customize our OkHttpClient to all requests made by react-native, it's very useful when you doSSL Pinning
or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient.Changelog:
[Android] [Added] - Websocket Module setCustomClientBuilder
Test Plan:
From the original PR:
You can just set a custom
CustomClientBuilder
onMainActivity
onCreate
: