-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fixes iOS reload through metro "r" command key #28477
Conversation
This allows the iOS device to be reloaded through the metro command line, besides the fact that whenever packagerServerHost is called, it will only get the IP address once when debugging.
Base commit: 6f627f6 |
Base commit: 6f627f6 |
Can you provide some more context as to why this is the correct change? Also, please include a test plan that shows to the reviewers of this PR that this change works. |
@TheSavior I think that this is the correct change because if no jsLocation is provided, the RCTBundleURLProvider will try to look for the device IP and use that to connect to metro. The problem is that since that is only used for the RCTBridge, the RCTPackagerConnection does not have access to it and tries then to connect either through jsLocation or localhost. Since iOS is not able to map localhost to the computer’s IP to which it is connected, it fails to connect to the websocket that allows the reload via “r” key on metro. Based on that and knowing that the IP is the method used when no jsLocation is specified, in my opinion it makes sense to only get the IP once and then set it as the jsLocation since it will be the way to anything (from that time on) to connect to the remote computer. |
Thanks for the context. I don't have any context on this code so I'll leave this PR for someone else to review / merge, but this additional info should make it easier for them. |
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.
I don't like assigning jsLocation inside a getter method like this. It will also have the side effect of saving the guessed host to NSUserDefaults
.
I think a better fix would be to use packagerServerHost
from RCTPackagerConnection
instead of jsLocation
. packagerServerHost
will need to be added to RCTBundleURLProvider
header in dev only (like isPackagerRunning
).
…Location since it is saved to NSUserDefaults
@janicduplessis I didn't notice that it would saved it to I did not make the access to |
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.
Thanks, LGTM!
ping @TheSavior
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.
@TheSavior has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This has failing unit tests:
While you fix this test can you make sure to add any additional tests that are needed to cover this change? |
@TheSavior I lack the experience with Unit Tests of such kind, specially on Obj C, which I know very little. How exactly can I check the failing test? Because the code I made was built directly on the react-native code that I have on a project and then moved to here once it worked well through the build. |
@reyalpsirc You can open RNTester/RNTesterPods.xcworkspace in xcode (make sure to also run pod install in the RNTester folder before). Then you can run tests there: |
@TheSavior do you have any more log about the failure? Weird because it passed OSS CI.
|
Ah. My guess is that since we run all of the tests without a network condition, something changed here causing it to try to make a network request. I'll retry the job to validate that it wasn't just a flake. Is there something in this test that was mocking this out before that isn't being used with now with this change? |
@TheSavior I checked the test that you mentioned on my side and it seemed to work: Also, correct me if I'm wrong but I think that it's not possible to build a test for this because it targets builds made for devices, which means that Automated tools like Circle CI would fail because they do not run these agains real devices? |
This pull request was successfully merged by @reyalpsirc in f9df933. When will my fix make it into a release? | Upcoming Releases |
Apparently it passed when I re ran it |
👍 Cool, found it weird that it failed since the PR doesn't actually touch the code that was tested by the failing test anymore (it did in the first version of the PR tho). |
Summary: This allows the iOS device to be reloaded through the metro command line, besides the fact that whenever packagerServerHost is called, it will only get the IP address once when debugging. ## Changelog [iOS] [Fixed] - Fixed connection of metro reload command to iOS device Pull Request resolved: facebook#28477 Test Plan: - Build any react-native project in debug mode to an iOS device connected through USB - Press the “r” key on the terminal that is running metro - The device should now reload the project Reviewed By: cpojer Differential Revision: D20818462 Pulled By: TheSavior fbshipit-source-id: 6d9792447d205223dad8fbd955518885427cbba8
Summary
This allows the iOS device to be reloaded through the metro command line, besides the fact that whenever packagerServerHost is called, it will only get the IP address once when debugging.
Changelog
[iOS] [Fixed] - Fixed connection of metro reload command to iOS device
Test Plan